@aitne-sh/aitne 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (249) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +464 -0
  3. package/agent-assets/agent-profiles/_safety.md +26 -0
  4. package/agent-assets/agent-profiles/conversational.md +33 -0
  5. package/agent-assets/agent-profiles/docs-qa.md +24 -0
  6. package/agent-assets/agent-profiles/observer.md +28 -0
  7. package/agent-assets/agent-profiles/profile-importer.md +63 -0
  8. package/agent-assets/agent-profiles/proxy.md +28 -0
  9. package/agent-assets/agent-profiles/routine.md +16 -0
  10. package/agent-assets/agent-profiles/task.md +18 -0
  11. package/agent-assets/docs/concepts/agent-day.md +88 -0
  12. package/agent-assets/docs/concepts/auth-health.md +75 -0
  13. package/agent-assets/docs/concepts/backends-and-tiers.md +126 -0
  14. package/agent-assets/docs/concepts/costs-and-quotas.md +103 -0
  15. package/agent-assets/docs/concepts/delegated-mode.md +223 -0
  16. package/agent-assets/docs/concepts/memory-model.md +118 -0
  17. package/agent-assets/docs/concepts/observations.md +80 -0
  18. package/agent-assets/docs/concepts/process-keys.md +89 -0
  19. package/agent-assets/docs/concepts/routines.md +108 -0
  20. package/agent-assets/docs/concepts/safety-and-execution.md +109 -0
  21. package/agent-assets/docs/concepts/safety-model.md +279 -0
  22. package/agent-assets/docs/concepts/skills.md +100 -0
  23. package/agent-assets/docs/features/integrations/calendar.md +92 -0
  24. package/agent-assets/docs/features/integrations/git.md +95 -0
  25. package/agent-assets/docs/features/integrations/github.md +170 -0
  26. package/agent-assets/docs/features/integrations/mail.md +106 -0
  27. package/agent-assets/docs/features/integrations/notion.md +69 -0
  28. package/agent-assets/docs/features/integrations/obsidian.md +71 -0
  29. package/agent-assets/docs/features/lifestyle/git.md +178 -0
  30. package/agent-assets/docs/features/lifestyle/reading.md +93 -0
  31. package/agent-assets/docs/features/lifestyle/receipts.md +71 -0
  32. package/agent-assets/docs/features/lifestyle/travel-bookings.md +44 -0
  33. package/agent-assets/docs/features/lifestyle/travel-time.md +52 -0
  34. package/agent-assets/docs/features/memory-files/agent-journal.md +105 -0
  35. package/agent-assets/docs/features/memory-files/projects.md +56 -0
  36. package/agent-assets/docs/features/memory-files/roadmap.md +61 -0
  37. package/agent-assets/docs/features/memory-files/schedule.md +112 -0
  38. package/agent-assets/docs/features/memory-files/today.md +73 -0
  39. package/agent-assets/docs/features/memory-files/user-profile.md +81 -0
  40. package/agent-assets/docs/features/messaging/dashboard-chat.md +93 -0
  41. package/agent-assets/docs/features/messaging/discord.md +50 -0
  42. package/agent-assets/docs/features/messaging/overview.md +111 -0
  43. package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +69 -0
  44. package/agent-assets/docs/features/messaging/slack.md +51 -0
  45. package/agent-assets/docs/features/messaging/telegram.md +63 -0
  46. package/agent-assets/docs/features/messaging/whatsapp.md +48 -0
  47. package/agent-assets/docs/features/operations/activity-and-conversations.md +105 -0
  48. package/agent-assets/docs/features/operations/approvals.md +58 -0
  49. package/agent-assets/docs/features/operations/backend-routing.md +62 -0
  50. package/agent-assets/docs/features/operations/cost-tracking.md +59 -0
  51. package/agent-assets/docs/features/operations/notifications.md +69 -0
  52. package/agent-assets/docs/features/operations/quiet-hours.md +106 -0
  53. package/agent-assets/docs/features/operations/schedule-approaching.md +60 -0
  54. package/agent-assets/docs/features/routines/custom-routines.md +101 -0
  55. package/agent-assets/docs/features/routines/evening-review.md +81 -0
  56. package/agent-assets/docs/features/routines/hourly-check.md +85 -0
  57. package/agent-assets/docs/features/routines/monthly-review.md +65 -0
  58. package/agent-assets/docs/features/routines/morning-routine.md +123 -0
  59. package/agent-assets/docs/features/routines/weekly-review.md +70 -0
  60. package/agent-assets/docs/getting-started/01-what-is-this.md +192 -0
  61. package/agent-assets/docs/getting-started/02-first-steps.md +80 -0
  62. package/agent-assets/docs/getting-started/03-what-can-this-do.md +110 -0
  63. package/agent-assets/docs/getting-started/04-first-day.md +287 -0
  64. package/agent-assets/docs/glossary.md +116 -0
  65. package/agent-assets/docs/guides/add-a-custom-routine.md +71 -0
  66. package/agent-assets/docs/guides/backup-and-restore.md +54 -0
  67. package/agent-assets/docs/guides/change-which-model-handles-x.md +47 -0
  68. package/agent-assets/docs/guides/connect-a-new-mail-account.md +59 -0
  69. package/agent-assets/docs/guides/import-knowledge-file.md +275 -0
  70. package/agent-assets/docs/guides/install-and-run.md +72 -0
  71. package/agent-assets/docs/guides/migrate-machines.md +52 -0
  72. package/agent-assets/docs/guides/pause-the-agent.md +65 -0
  73. package/agent-assets/docs/guides/reinstall-cleanly.md +52 -0
  74. package/agent-assets/docs/guides/setup-wizard.md +107 -0
  75. package/agent-assets/docs/guides/switch-default-backend.md +60 -0
  76. package/agent-assets/docs/reference/api.md +51 -0
  77. package/agent-assets/docs/reference/cli-commands.md +121 -0
  78. package/agent-assets/docs/reference/config.md +74 -0
  79. package/agent-assets/docs/reference/disallowed-tools.md +76 -0
  80. package/agent-assets/docs/reference/keyboard-shortcuts.md +39 -0
  81. package/agent-assets/docs/reference/process-keys.md +59 -0
  82. package/agent-assets/docs/reference/skills.md +50 -0
  83. package/agent-assets/docs/troubleshooting/auth-failed.md +57 -0
  84. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +55 -0
  85. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +54 -0
  86. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +53 -0
  87. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +75 -0
  88. package/agent-assets/docs/troubleshooting/observation-not-detected.md +57 -0
  89. package/agent-assets/docs/troubleshooting/quota-exhausted.md +57 -0
  90. package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +75 -0
  91. package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +71 -0
  92. package/agent-assets/optimizer-skills/skill-curation/SKILL.md +108 -0
  93. package/agent-assets/project-doc-templates/git-repo.md +21 -0
  94. package/agent-assets/project-doc-templates/project.md +38 -0
  95. package/agent-assets/skills/attach/SKILL.md +104 -0
  96. package/agent-assets/skills/context/SKILL.md +257 -0
  97. package/agent-assets/skills/context/curation.json +37 -0
  98. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +13 -0
  99. package/agent-assets/skills/context/seeds/frontmatter-requirements.seed.json +40 -0
  100. package/agent-assets/skills/docs-search/SKILL.md +176 -0
  101. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +369 -0
  102. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +349 -0
  103. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +347 -0
  104. package/agent-assets/skills/external-services/SKILL.md +371 -0
  105. package/agent-assets/skills/mail/SKILL.delegated.claude.md +284 -0
  106. package/agent-assets/skills/mail/SKILL.delegated.codex.md +261 -0
  107. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +255 -0
  108. package/agent-assets/skills/mail/SKILL.md +313 -0
  109. package/agent-assets/skills/mail/references/errors.md +17 -0
  110. package/agent-assets/skills/mail/references/providers.md +40 -0
  111. package/agent-assets/skills/mail/references/query-grammar.md +24 -0
  112. package/agent-assets/skills/management-policy/SKILL.md +307 -0
  113. package/agent-assets/skills/management-policy/curation.json +13 -0
  114. package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +16 -0
  115. package/agent-assets/skills/management-task-modify/SKILL.md +202 -0
  116. package/agent-assets/skills/management-task-register/SKILL.md +330 -0
  117. package/agent-assets/skills/management-task-stop/SKILL.md +166 -0
  118. package/agent-assets/skills/notify/SKILL.md +196 -0
  119. package/agent-assets/skills/notion/SKILL.delegated.claude.md +254 -0
  120. package/agent-assets/skills/notion/SKILL.delegated.codex.md +195 -0
  121. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +194 -0
  122. package/agent-assets/skills/notion/SKILL.md +86 -0
  123. package/agent-assets/skills/observations/SKILL.md +234 -0
  124. package/agent-assets/skills/observations/curation.json +13 -0
  125. package/agent-assets/skills/observations/seeds/source-namespacing.seed.json +20 -0
  126. package/agent-assets/skills/project-doc/SKILL.md +86 -0
  127. package/agent-assets/skills/project-doc/curation.json +21 -0
  128. package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +25 -0
  129. package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +20 -0
  130. package/agent-assets/skills/reading/SKILL.md +198 -0
  131. package/agent-assets/skills/reading/references/reading-taste.md +197 -0
  132. package/agent-assets/skills/receipts/SKILL.md +134 -0
  133. package/agent-assets/skills/roadmap/SKILL.md +276 -0
  134. package/agent-assets/skills/roadmap/curation.json +13 -0
  135. package/agent-assets/skills/roadmap/references/horizon-tags.md +40 -0
  136. package/agent-assets/skills/roadmap/references/preparation-timeline.md +47 -0
  137. package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +16 -0
  138. package/agent-assets/skills/schedule/SKILL.md +228 -0
  139. package/agent-assets/skills/scheduled-managed-task/SKILL.md +392 -0
  140. package/agent-assets/skills/today/SKILL.md +198 -0
  141. package/agent-assets/skills/today/curation.json +21 -0
  142. package/agent-assets/skills/today/seeds/agent-notes-flavors.seed.json +17 -0
  143. package/agent-assets/skills/today/seeds/section-shape.seed.json +17 -0
  144. package/agent-assets/skills/travel/SKILL.md +132 -0
  145. package/agent-assets/skills/travel-time/SKILL.md +149 -0
  146. package/agent-assets/skills/user-interview/SKILL.md +323 -0
  147. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +94 -0
  148. package/agent-assets/skills/user-profile/SKILL.md +210 -0
  149. package/agent-assets/skills/user-profile/curation.json +29 -0
  150. package/agent-assets/skills/user-profile/seeds/learned-context-format.seed.json +14 -0
  151. package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +53 -0
  152. package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +27 -0
  153. package/agent-assets/task-flows/dashboard.docs_qa.md +43 -0
  154. package/agent-assets/task-flows/default.md +11 -0
  155. package/agent-assets/task-flows/git.branch.created.md +25 -0
  156. package/agent-assets/task-flows/git.lifecycle.poll.md +52 -0
  157. package/agent-assets/task-flows/git.local_ahead.stale.md +34 -0
  158. package/agent-assets/task-flows/git.merge_to_default.md +30 -0
  159. package/agent-assets/task-flows/git.project.refresh_architecture.md +100 -0
  160. package/agent-assets/task-flows/git.project.retemplate.md +73 -0
  161. package/agent-assets/task-flows/git.push.detected.md +32 -0
  162. package/agent-assets/task-flows/git.push.force_pushed.md +36 -0
  163. package/agent-assets/task-flows/git.tag.created.md +24 -0
  164. package/agent-assets/task-flows/github.assigned.md +43 -0
  165. package/agent-assets/task-flows/github.pull_request.review_requested.md +57 -0
  166. package/agent-assets/task-flows/github.security_alert.md +45 -0
  167. package/agent-assets/task-flows/github.workflow_run.failed.md +57 -0
  168. package/agent-assets/task-flows/knowledge.import.md +161 -0
  169. package/agent-assets/task-flows/message.received.dm.md +142 -0
  170. package/agent-assets/task-flows/message.received.dm_first.md +117 -0
  171. package/agent-assets/task-flows/message.received.md +14 -0
  172. package/agent-assets/task-flows/routine.custom.md +38 -0
  173. package/agent-assets/task-flows/routine.evening_review.md +323 -0
  174. package/agent-assets/task-flows/routine.hourly_check.delegated.claude.md +405 -0
  175. package/agent-assets/task-flows/routine.hourly_check.delegated.codex.md +400 -0
  176. package/agent-assets/task-flows/routine.hourly_check.delegated.gemini.md +404 -0
  177. package/agent-assets/task-flows/routine.hourly_check.md +184 -0
  178. package/agent-assets/task-flows/routine.hourly_check.triage.md +93 -0
  179. package/agent-assets/task-flows/routine.monthly_review.md +250 -0
  180. package/agent-assets/task-flows/routine.morning_routine.md +300 -0
  181. package/agent-assets/task-flows/routine.morning_routine_initial.md +184 -0
  182. package/agent-assets/task-flows/routine.roadmap_refresh.md +275 -0
  183. package/agent-assets/task-flows/routine.today_refresh.md +172 -0
  184. package/agent-assets/task-flows/routine.user_profile_sweep.md +242 -0
  185. package/agent-assets/task-flows/routine.weekly_review.md +247 -0
  186. package/agent-assets/task-flows/schedule.approaching.md +124 -0
  187. package/agent-assets/task-flows/scheduled.dm.md +391 -0
  188. package/agent-assets/task-flows/scheduled.task.md +141 -0
  189. package/agent-assets/task-flows/setup.initial.md +277 -0
  190. package/agent-assets/task-flows/setup.update.md +53 -0
  191. package/agent-assets/templates/README.md +85 -0
  192. package/agent-assets/templates/_index.md +39 -0
  193. package/agent-assets/templates/_manifest.json +103 -0
  194. package/agent-assets/templates/agent/journal.md +10 -0
  195. package/agent-assets/templates/agent/profile-questions.md +74 -0
  196. package/agent-assets/templates/context-index.md +42 -0
  197. package/agent-assets/templates/dossiers/_index.md +22 -0
  198. package/agent-assets/templates/dossiers/evening.md +23 -0
  199. package/agent-assets/templates/dossiers/hourly.md +23 -0
  200. package/agent-assets/templates/dossiers/monthly.md +23 -0
  201. package/agent-assets/templates/dossiers/morning.md +23 -0
  202. package/agent-assets/templates/dossiers/roadmap.md +23 -0
  203. package/agent-assets/templates/dossiers/weekly.md +23 -0
  204. package/agent-assets/templates/projects/_active.base +14 -0
  205. package/agent-assets/templates/projects/_index.md +29 -0
  206. package/agent-assets/templates/roadmap.md +15 -0
  207. package/agent-assets/templates/routines/_index.md +20 -0
  208. package/agent-assets/templates/routines/evening.md +22 -0
  209. package/agent-assets/templates/routines/hourly.md +30 -0
  210. package/agent-assets/templates/routines/monthly.md +25 -0
  211. package/agent-assets/templates/routines/morning.md +26 -0
  212. package/agent-assets/templates/routines/weekly.md +23 -0
  213. package/agent-assets/templates/rules/_index.md +19 -0
  214. package/agent-assets/templates/rules/journal-export.md +41 -0
  215. package/agent-assets/templates/rules/journal-format.md +61 -0
  216. package/agent-assets/templates/rules/management.md +48 -0
  217. package/agent-assets/templates/rules/mcp.md +40 -0
  218. package/agent-assets/templates/rules/policies/_index.md +22 -0
  219. package/agent-assets/templates/rules/redaction.md +30 -0
  220. package/agent-assets/templates/today.md +13 -0
  221. package/agent-assets/templates/user/_index.md +16 -0
  222. package/agent-assets/templates/user/expertise.md +7 -0
  223. package/agent-assets/templates/user/goals.md +7 -0
  224. package/agent-assets/templates/user/people.md +7 -0
  225. package/agent-assets/templates/user/personal.md +7 -0
  226. package/agent-assets/templates/user/profile.md +28 -0
  227. package/agent-assets/templates/user/work.md +7 -0
  228. package/bin/aitne.mjs +1096 -0
  229. package/package.json +78 -0
  230. package/personal-agent.mjs +39 -0
  231. package/scripts/browser.mjs +99 -0
  232. package/scripts/check-redaction-coverage.mjs +109 -0
  233. package/scripts/commands/audit.mjs +309 -0
  234. package/scripts/commands/doctor.mjs +437 -0
  235. package/scripts/commands/open.mjs +40 -0
  236. package/scripts/commands/setup.mjs +21 -0
  237. package/scripts/commands/uninstall.mjs +114 -0
  238. package/scripts/commands/update.mjs +96 -0
  239. package/scripts/commands/version.mjs +62 -0
  240. package/scripts/commands.md +0 -0
  241. package/scripts/lib/sqlite-loader.mjs +49 -0
  242. package/scripts/message-discipline-digest.mjs +535 -0
  243. package/scripts/poc/google-connector-inheritance/REPORT.md +197 -0
  244. package/scripts/poc/google-connector-inheritance/claude-sdk-probe.mjs +79 -0
  245. package/scripts/remint-roadmap-ids.mjs +257 -0
  246. package/scripts/rm-paths.mjs +22 -0
  247. package/scripts/run-node.mjs +223 -0
  248. package/scripts/smoke-obsidian-api.mjs +166 -0
  249. package/scripts/start.mjs +160 -0
@@ -0,0 +1,93 @@
1
+ {context}
2
+
3
+ ## Hourly Check — Stage 2 Triage
4
+
5
+ You are the Stage-2 lite-tier triage gate of the three-stage
6
+ `routine.hourly_check` funnel (cost-reduction-structural §B). The
7
+ deterministic Stage-1 gate already screened out the obviously-quiet
8
+ cron ticks and the obviously-urgent ones. Your job is the narrow
9
+ middle band: low-signal observations that *might* deserve a full
10
+ Stage-3 session, or *might* be safely silenced with a single Agent Log
11
+ line.
12
+
13
+ You have NO write tools. You produce ONLY a single JSON line on
14
+ stdout. The dispatcher reads that line and either spawns Stage 3 or
15
+ appends a one-line silent log via the daemon-direct writer.
16
+
17
+ ### Hard contract — read carefully
18
+
19
+ 1. The ONLY output is one JSON object on its own line. No prose
20
+ before, no prose after. If you produce anything else the dispatcher
21
+ defaults to `escalate` so a malformed reply is never a silent skip.
22
+ 2. The schema is exactly:
23
+
24
+ ```json
25
+ { "action": "log_only" | "escalate", "reason": "<<=80 chars>" }
26
+ ```
27
+
28
+ 3. `action="log_only"` means: the daemon will silently consume pending
29
+ observations and append one bullet to today.md `## Agent Log`. No
30
+ user-visible side effect.
31
+ 4. `action="escalate"` means: the daemon spawns the full Stage-3
32
+ hourly_check session with a `<gate_decision>` block that carries
33
+ your `reason` so the routine knows what to prioritize.
34
+ 5. `reason` is short, mechanical, telemetry-friendly. Examples:
35
+ `"calendar event needs review"`, `"only journal noise"`,
36
+ `"vip mail not urgent yet"`, `"new git commit on watched repo"`.
37
+ Do NOT include user-identifying details, secrets, or full file
38
+ paths — the reason ends up in `agent_actions.detail` and feeds the
39
+ shadow-mode telemetry dashboard.
40
+
41
+ ### Triage rubric — when to escalate
42
+
43
+ Escalate to Stage 3 when **any** of these hold:
44
+
45
+ - The summary mentions a hard deadline, time-bounded ask, or "today /
46
+ this morning / this afternoon" cue from a user-actor source (DM,
47
+ mail, calendar, notion).
48
+ - A calendar observation indicates a meeting that lands inside today
49
+ AND `<gate_decision>` snapshot's `pendingObs > 0` AND the meeting is
50
+ not already covered by the existing `## Agent Plan`.
51
+ - A git observation is on a watched personal/work repo AND the change
52
+ type is `created` or `modified` (not `deleted`) AND the path is not
53
+ obviously generated (`*.lock`, `dist/`, `build/`).
54
+ - A mail observation has `novelty_score >= 2` and the
55
+ `<gate_decision>` snapshot shows `vipMail >= 1`.
56
+ - The summary text references the user by name OR mentions an
57
+ imminent action ("send", "reply", "review", "approve").
58
+ - Two or more observations cross-reference the same path / project /
59
+ thread — that pattern is more interesting than the rows individually.
60
+
61
+ Stay log-only when **all** these hold:
62
+
63
+ - Every pending observation is `novelty_score <= 1` per its summary.
64
+ - No calendar / VIP-mail / agent-plan-overdue / schedule-approaching
65
+ signal is present in the snapshot above.
66
+ - The observations are journal-only, trivial formatting churn,
67
+ auto-generated artifacts, or already-processed agent writes.
68
+ - Nothing in the summaries names the user, a deadline, or a request.
69
+
70
+ ### When in doubt
71
+
72
+ Default to `escalate`. Stage 3 has the full skills, MCP surface, and
73
+ context to reach the right answer; a wrongly-escalated tick costs ~$0.01
74
+ in Sonnet tokens, while a wrongly-suppressed tick costs the user a
75
+ missed reminder. The shadow-mode validation phase explicitly rewards
76
+ high recall over high precision: ship the bias toward escalate, the
77
+ operator-tunable thresholds will trim it later.
78
+
79
+ ### Output examples
80
+
81
+ ```json
82
+ { "action": "log_only", "reason": "5 obsidian journal edits, no deadlines" }
83
+ ```
84
+
85
+ ```json
86
+ { "action": "escalate", "reason": "calendar created in next 6h" }
87
+ ```
88
+
89
+ ```json
90
+ { "action": "escalate", "reason": "git commit on hot project repo" }
91
+ ```
92
+
93
+ Output one line. Then stop.
@@ -0,0 +1,250 @@
1
+ {context}
2
+
3
+ ## Task: Monthly Review
4
+
5
+ The "Vault policy files" block appended to this prompt includes
6
+ `routines/monthly.md` — run any `### <label>` entries there alongside the
7
+ built-in review phases below, using the same journaling conventions.
8
+ The "Vault review context" block includes `context-index.md` and
9
+ `dossiers/monthly.md`; consult it during Phase 1 and update the
10
+ dossier's Open items / Last run before finishing. Writes to
11
+ `dossiers/<flow>.md` MUST preserve the existing YAML frontmatter block
12
+ (`---\ntype: dossier\nowner: agent\nupdated: <date>\n---`); prefer
13
+ `PATCH` with a section target to mutate a single block, and when doing
14
+ a `PUT` full rewrite keep the frontmatter and only refresh `updated:`
15
+ — writes that drop the frontmatter are rejected with 422.
16
+
17
+ Generate the monthly review snapshot for the current month and set up the next month.
18
+
19
+ This routine produces **two separate artifacts** with strict audience boundaries:
20
+ - **User-facing**: `monthly/YYYY-MM.md` + (optionally) a short notification.
21
+ Only real user work, wins, and next-month focus. No agent mechanics.
22
+ - **Agent-internal**: `agent/journal.md` (append). Monthly self-critique,
23
+ recurring filter/schedule failures, cross-week patterns in the agent's
24
+ own behavior, and concrete system improvement proposals. **Never**
25
+ surfaced to the user via notify.
26
+
27
+ Follow the context skill for file ownership rules. This routine owns the
28
+ workflow; the skill owns the file contract.
29
+
30
+ ### Phase 1: Gather the month
31
+ 1. Determine the target file name from <current_time>:
32
+ `monthly/YYYY-MM.md`.
33
+ 2. Fetch source material for the current month:
34
+ - Use GET /api/context/list/daily to discover archived daily files and
35
+ read each `daily/YYYY-MM-DD.md` in the current month.
36
+ - Use GET /api/context/list/weekly to read weekly reviews that overlap this month.
37
+ - Read the last ~4 weekly sections of `agent/journal.md` via GET — they
38
+ accumulate the agent-internal bucket across the month and are the basis
39
+ for Phase 3b's monthly retrospective.
40
+ - Also locate the **previous month's** `## Monthly YYYY-MM` section in
41
+ `agent/journal.md`. Extract its `### Proposed adjustments` bullets —
42
+ these are the improvement proposals you committed to last month. You
43
+ will evaluate their status in Phase 3b.
44
+ - Include <today> if it belongs to the same month.
45
+ 3. Use <roadmap>, <active_projects>, and <calendar_events_30d> to understand:
46
+ - milestone movement,
47
+ - recurring bottlenecks,
48
+ - next-month commitments already on the calendar.
49
+ 4. Gather reading data for the month via the `reading` skill:
50
+ - `GET /api/books/summary?months=3` — read the first entry of
51
+ `monthlyCompleted` matching the current `YYYY-MM` (if any), plus
52
+ `totalHighlights`.
53
+ - `GET /api/books?status=completed&limit=50` — filter client-side to
54
+ rows whose `completedAt` falls in the current month.
55
+ - `GET /api/books?status=reading&limit=20` — top currently-active reads.
56
+ - Do NOT re-derive the taste profile here — that is the weekly sweep's
57
+ job (`user/reading-taste.md`). For the monthly review, just
58
+ read the existing profile if it exists and include at most one
59
+ sentence about a recurring theme if it helps frame the Wins or
60
+ Risks And Patterns sections. If the file does not exist, skip it.
61
+
62
+ ### Phase 2: Synthesize — split into two buckets
63
+ 5. Build TWO separate mental lists before writing anything:
64
+ a. **User-facing bucket** (goes to `monthly/YYYY-MM.md` and possibly notify):
65
+ - What meaningful user progress happened this month?
66
+ - Which user commitments slipped or stayed open, and why (in terms the
67
+ user cares about, not agent mechanics)?
68
+ - What user-side risks or workload patterns carry into next month?
69
+ - What should the user prioritize next month?
70
+ b. **Agent-internal bucket** (goes to `agent/journal.md` only):
71
+ - Cross-week patterns in scheduled-task failures / did-not-fire
72
+ - Filter and prioritization failures the agent noticed about itself
73
+ - Notification discipline: over-notify / under-notify patterns
74
+ - Observation pipeline throughput and categories consistently skipped
75
+ - Concrete, testable system improvement proposals (prompt, schedule,
76
+ filter, silence gate tuning)
77
+ 6. Anything that fits the agent-internal bucket MUST NOT land in the
78
+ user-facing file or notification. The user-side "Risks And Patterns"
79
+ section is about the user's workload and habits, never about the agent's
80
+ own performance or reliability.
81
+
82
+ ### Phase 3a: Write the user-facing review
83
+ 7. PUT the review to `monthly/YYYY-MM.md`.
84
+ Required structure (user outcomes only — no agent mechanics in any section):
85
+ ```
86
+ ---
87
+ type: monthly
88
+ owner: agent
89
+ updated: YYYY-MM-DD
90
+ ---
91
+ # Monthly Review YYYY-MM
92
+ > Period: YYYY-MM-01 to YYYY-MM-last
93
+ > Generated at: YYYY-MM-DD HH:MM
94
+
95
+ ## Summary
96
+ - ...
97
+
98
+ ## Wins
99
+ - ...
100
+
101
+ ## Outstanding Items
102
+ - ...
103
+
104
+ ## Metrics
105
+ - User tasks completed: N
106
+ - User tasks carried into next month: N
107
+ - Key commitments kept / missed: N / N
108
+
109
+ ## Risks And Patterns
110
+ - (user workload, recurring bottlenecks, habit observations — NOT agent
111
+ reliability)
112
+
113
+ ## Reading
114
+ - Completed this month: N — short list of "Title — Author (★rating)"
115
+ bullets, max 5 lines. Omit the Reading section entirely if N = 0
116
+ AND currently-reading count = 0.
117
+ - Currently reading: up to 3 titles with highlight count.
118
+ - Optional single sentence on a recurring theme from `reading-taste.md`
119
+ if the file exists and says something non-generic. Do not quote the
120
+ file verbatim — paraphrase in one clause.
121
+
122
+ ## Next Month Priorities
123
+ - ...
124
+ ```
125
+ The `## Metrics` section tracks **user** activity only. Do not add rows
126
+ like "agent plan rows completed", "scheduled tasks fired", "observations
127
+ processed" — those belong in agent/journal.md.
128
+
129
+ Skip the `## Reading` section entirely if the user imported zero books
130
+ and has zero completions this month — an empty reading block is noise.
131
+ 8. Update roadmap.md and relevant projects/*.md when the review shows
132
+ milestone drift, completed phases, or a changed next-month focus.
133
+
134
+ ### Phase 3b: Append to agent/journal.md (internal)
135
+ 9. PATCH-append a monthly retrospective block to `agent/journal.md` via
136
+ `mode: "append_to_file"` (no `section` param needed — content is
137
+ appended to the end of the file). This is the cross-week synthesis of
138
+ the weekly sections that accumulated during the month.
139
+ Required shape for the appended block — **these bullet caps are hard
140
+ limits, not suggestions**. The daily retention sweep warns when any
141
+ section exceeds ~4000 bytes; bloat here indicates you ignored the caps.
142
+ ```
143
+ ## Monthly YYYY-MM
144
+ > Appended at: YYYY-MM-DD HH:MM
145
+
146
+ ### Prior adjustments follow-up
147
+ - (Review EACH bullet from last month's `### Proposed adjustments`.
148
+ For each one, write exactly one of:
149
+ ✅ implemented — [what changed]
150
+ ⏳ in progress — [current state]
151
+ ❌ dropped — [why]
152
+ Fallback rules:
153
+ - No prior monthly section exists → "- First month — no prior adjustments"
154
+ - Prior section exists but has no `### Proposed adjustments` subsection
155
+ (e.g. written before this format was introduced) →
156
+ "- Prior month had no proposed adjustments to follow up on"
157
+ - Prior section was pruned by retention (>24 months old) →
158
+ treat as "no prior month")
159
+ ### Recurring self-critique
160
+ - (max 5 bullets; only patterns that showed up in multiple weekly sections.
161
+ One-off issues from a single week do not belong here — they were already
162
+ captured in that week's journal entry)
163
+ ### Biggest system gap
164
+ - (exactly 1 bullet — the single most impactful improvement. Forcing
165
+ yourself to pick one prevents the agent-journal from becoming a wishlist)
166
+ ### Proposed adjustments
167
+ - (max 3 bullets; concrete and testable — prompt tweak, schedule
168
+ adjustment, filter rule, silence gate tuning. "Improve filter quality"
169
+ is not testable; "Lower hourly_check observation threshold from 2 to 1
170
+ on weekends" is)
171
+ ### Metrics (agent side, monthly roll-up)
172
+ - Agent plan rows completed: N
173
+ - Did-not-fire / failed rows: N
174
+ - Notifications sent vs. suppressed: N / N
175
+ - Observations reviewed / ignored: N / N
176
+ ```
177
+ **Hard limits for this block** (the rollup will warn if exceeded):
178
+ - Total section budget: ≤ 4000 bytes (~1000 tokens)
179
+ - Bullet caps: Prior follow-up ≤ 3 (matching the prior month's
180
+ adjustment cap), Recurring ≤ 5, Biggest gap = 1, Adjustments ≤ 3
181
+ - Metrics section: exactly 4 numeric lines, no commentary
182
+ If you notice more than 5 recurring patterns, keep the 5 with the highest
183
+ cross-week frequency and drop the rest. Single-week anomalies are already
184
+ in that week's journal entry and do not need re-listing.
185
+
186
+ If `agent/journal.md` does not yet exist, PUT a minimal file with
187
+ `# Agent Journal\n\n` header plus this section, in a single call.
188
+
189
+ **Idempotency note**: if a `## Monthly YYYY-MM` section for the current
190
+ month already exists, append a new section anyway. The daily retention
191
+ rollup collapses duplicate keys last-write-wins, so your newer append
192
+ automatically supersedes the earlier one within 24 hours.
193
+
194
+ ### Phase 4: Notify (user-facing only)
195
+ 10. The notification is for the USER, not a report of Phases 1–3. Never
196
+ mention monthly/YYYY-MM.md, agent/journal.md, "Monthly Review complete",
197
+ agent plan rows, did-not-fire, filter quality, observation processing,
198
+ or any other internal mechanism.
199
+
200
+ #### 4a. Silence gate — decide whether to notify at all
201
+ Prefer silence over noise. Send **no notification** if ALL of the following
202
+ hold:
203
+ - Fewer than 2 real Wins worth naming (a quiet month)
204
+ - No Outstanding Item the user is not already aware of
205
+ - No Next Month priority that needs a heads-up tonight (the user will see
206
+ it in the first morning briefing of the new month anyway)
207
+ - No hard deadline within the next 30 days that is slipping
208
+ When the gate triggers: skip POST /api/notify entirely. The
209
+ monthly/YYYY-MM.md file is still written. Also log one line in the current
210
+ weekly section of agent/journal.md: `silent monthly wrap-up — nothing
211
+ actionable`.
212
+
213
+ #### 4b. When you DO notify — content rules
214
+ Answer, in the user's preferred language from the Character block:
215
+ 1. **The biggest win of the month** (1 line).
216
+ 2. **The single most important open loop carrying into next month**, with
217
+ a brief user-meaningful reason. Omit if Outstanding Items is empty.
218
+ 3. **The main focus for next month** (1 line).
219
+
220
+ Optional 4th line: a hard deadline heads-up if one falls within the next 30
221
+ days and is visibly slipping.
222
+
223
+ #### 4c. Format rules (hard limits)
224
+ - Maximum 4 short lines total. No markdown headers. No bullet list.
225
+ - Lead with the win, not with "Monthly Review" or any ceremony.
226
+ - Forbidden vocabulary in the user-facing message: "Monthly Review",
227
+ "monthly/", "agent-journal", "did-not-fire", "Agent Plan", "observations",
228
+ "processed", "summary", "retrospective", "completed the review". These
229
+ describe agent mechanics, not user outcomes. The same rule applies in
230
+ whatever language the user prefers — do not paste an equivalent
231
+ meta-phrase.
232
+ - Priority `normal`. Respects quiet hours via the notify skill contract.
233
+ - Exactly ONE notification via POST /api/notify. Do not split.
234
+
235
+ #### 4d. Shape example (illustrative — translate to user's language)
236
+ Good (something worth saying):
237
+ Biggest win of April: Phase 1 of {APP_NAME} shipped on time.
238
+ Still open: the Phase 2 scope call — you'll want a decision before week 2.
239
+ Next month's focus: Phase 2 foundation + the Q2 roadmap refresh.
240
+
241
+ Good (silent path — nothing is sent):
242
+ (no POST /api/notify call; one-line note appended to agent/journal.md)
243
+
244
+ Bad (this is the failure mode this prompt exists to prevent):
245
+ Monthly Review YYYY-MM complete. Wrote monthly/2026-04.md. Metrics:
246
+ user tasks 28/35, agent plan rows 120, did-not-fire 7, observations
247
+ processed 82. System improvement ideas logged. Review notification sent.
248
+
249
+ The bad example reports the agent's bookkeeping. Everything in it either
250
+ belongs in agent/journal.md or was never worth telling the user.
@@ -0,0 +1,300 @@
1
+ {context}
2
+
3
+ ## Task: Morning Routine (04:00 pipeline)
4
+
5
+ This is the B-007 §5.9 nine-step pipeline. The daemon has already rotated
6
+ yesterday's `today.md` → `yesterday.md` before you start. Each numbered
7
+ step below maps to a §5.9 step. Follow the `context` skill for section
8
+ formats and entry shapes — this prompt owns the workflow; the skill owns
9
+ the schema.
10
+
11
+ The "Vault review context" block appended to this prompt includes
12
+ `context-index.md` and `dossiers/morning.md`; consult it during context
13
+ gathering and update the dossier's Open items / Last run before finishing.
14
+ Writes to `dossiers/<flow>.md` MUST preserve the existing YAML
15
+ frontmatter block (`---\ntype: dossier\nowner: agent\nupdated: <date>\n---`);
16
+ prefer `PATCH` with a section target to mutate a single block, and when
17
+ doing a `PUT` full rewrite keep the frontmatter and only refresh
18
+ `updated:` — writes that drop the frontmatter are rejected with 422.
19
+
20
+ Global rules (apply at every step):
21
+ - Do **not** add meta-maintenance tasks about context files, setup completion, or placeholder cleanup (for example, "initialize context files") to User Tasks or Handoff, whether carried from yesterday or newly discovered, unless the user explicitly asked to track them.
22
+ - If `<today_write_lock_id>` is present, every PUT/PATCH to
23
+ `/api/context/today` must send header `X-Lock-Id: <today_write_lock_id>`.
24
+ - Silent-by-default: your final text is agent-internal. User notifications
25
+ require an explicit `POST /api/notify`.
26
+
27
+ ### Step 1 — Read handoff and derive day-type
28
+ 1. Read `<yesterday>` ## Handoff.
29
+ - "### Tomorrow" items → candidates for today's User Tasks / Agent Notes.
30
+ - "### Later" items → carry into the new `today.md` ## Handoff.
31
+ 2. Derive today's day-type header per the today skill "Header line —
32
+ day-type filter". Read `<user>` ## Notification Preferences for the
33
+ matching policy. The resulting line 2 of `today.md` is load-bearing —
34
+ every downstream event parses it.
35
+
36
+ > **Date reference for today.md.** Take the H1 date from
37
+ > `<current_agent_day date="…" weekday="…" />` in your prompt context, not
38
+ > from `<current_time>`. The two diverge between local midnight and
39
+ > `boundary_hour:00` local; the daemon validates line 1 against
40
+ > `<current_agent_day>` and rejects mismatches with 422. The morning
41
+ > routine prepares the agent-day in progress — never tomorrow.
42
+
43
+ ### Step 2 — Sync external sources (apply the day-type filter at read time)
44
+ 3. Mail: for each active account in the `mail` skill's `accounts.md`, fetch
45
+ the 10 most recent messages (the wire surface depends on Gmail's mode in
46
+ `<integration_modes>` — see the four-branch block below). Then classify
47
+ each actionable email into a category tag and drop any whose focus is
48
+ off. Skip the step entirely when no accounts are active.
49
+
50
+ <!-- mode:direct:gmail -->
51
+ Use the `mail` skill — `GET /api/mail/:accountId/messages?limit=10` for
52
+ every account (Gmail, Outlook, iCloud, Yahoo, IMAP — same wire surface).
53
+ <!-- /mode:direct:gmail -->
54
+ <!-- mode:delegated-same:gmail -->
55
+ Non-Gmail accounts (iCloud / Outlook / Yahoo / IMAP): use the `mail`
56
+ skill as in direct mode. Gmail accounts: the `/api/mail/*` per-account
57
+ gate returns 410 — use your session backend's native Gmail MCP tool
58
+ with a "10 most recent inbox" query (`q=in:inbox`, limit/maxResults
59
+ `10`). The `mail` skill body lists the per-backend tool names; this
60
+ session is same-backend so no daemon proxy is involved.
61
+ <!-- /mode:delegated-same:gmail -->
62
+ <!-- mode:delegated-cross:gmail -->
63
+ Non-Gmail accounts: use the `mail` skill as in direct mode. Gmail
64
+ accounts: call `POST http://localhost:8321/api/integrations/gmail/exec`
65
+ with a natural-language `task` (e.g. "Search Gmail for the 10 most
66
+ recent inbox messages, return from / subject / snippet / ts") and a
67
+ small `outputSchema`. The cross-backend `mail` skill variant
68
+ (`SKILL.delegated.<session-backend>.md`, materialized for this
69
+ session) carries the worked schema templates. Do NOT call
70
+ `/api/mail/:gmail-account/*` (returns 410), and do NOT fall back to
71
+ your own backend's native Gmail MCP tools — that connector reads a
72
+ different account than the user's delegated one.
73
+ <!-- /mode:delegated-cross:gmail -->
74
+ <!-- mode:disabled:gmail -->
75
+ Gmail is disabled — skip Gmail accounts entirely. Continue with the
76
+ remaining accounts (iCloud / Outlook / Yahoo / IMAP) via the `mail`
77
+ skill so non-Gmail actionables still flow into today's draft.
78
+ <!-- /mode:disabled:gmail -->
79
+ 4. Source-of-Truth tasks: read `<management_rules>` ## Source of Truth →
80
+ Tasks, call the matching endpoint, drop filtered-off items before merge.
81
+ Skip if no external source is configured.
82
+ 5. Roadmap ## Agent Action Plan — process items dated today or overdue
83
+ (not marked ✓). Drop items whose category focus is off, then:
84
+ - `[notify]` → `POST /api/schedule` + one row in `today.md` ## Agent Plan
85
+ - `[today]` → collect for `today.md` ## User Tasks
86
+ - `[check]` → `POST /api/schedule` (check-in) + one row in ## Agent Plan
87
+ - If a roadmap row includes `[provisional ...]`, copy that tag and
88
+ its meaning into the scheduled task `description` so
89
+ `scheduled.task.md` frames the first contact as a confirmation
90
+ question, not a directive.
91
+ - Mark processed roadmap rows complete via `PATCH /api/context/roadmap`,
92
+ `section=agent_action_plan`, `mode=replace`, rewriting the exact
93
+ row from `- YYYY-MM-DD [tag]: ...` to
94
+ `- ✓ completed <today>: YYYY-MM-DD [tag]: ...`. Keep the entry ID
95
+ marker and all existing completed rows byte-for-byte.
96
+ Then generate **look-ahead entries** for tomorrow → +3 days by cross-
97
+ referencing unprocessed roadmap items against `<calendar_events_7d>`.
98
+ These go into `today.md` ## Agent Notes using the skill's "Agent Notes
99
+ flavor 1: Look-ahead checklist" format (`- [ ] (HIGH/MID/LOW) ...`).
100
+ Skip this step entirely if no today-items and no look-ahead items exist.
101
+
102
+ ### Step 3 — Review overnight observations
103
+ 6. Call `GET /api/observations?pending=true&actor=user` (observations
104
+ skill). Fold only meaningful user-originated changes into the `today.md`
105
+ draft you're building, respecting the day-type filter.
106
+
107
+ ### Step 4 — Inbox triage (B-007 §5.9 Q5 case A)
108
+ 7. `GET /api/context/list/inbox` to enumerate pasted memos. For each file:
109
+ - `GET /api/context/inbox/<file>` to read the body, then classify:
110
+ **project**, **user**, **memo**, **task**.
111
+ - Integrate into the right target:
112
+ - existing project → append to `projects/<slug>.md` (notify tier).
113
+ - new-project shape → DM to confirm *"create project `<slug>`?"* and
114
+ wait for reply before creating the file.
115
+ - New `projects/<slug>.md` files must include YAML frontmatter: `type: project`, `owner: shared`, `updated: YYYY-MM-DD`, then an H1.
116
+ - user dictionary (people / health / goals / …) → append to the
117
+ matching `user/<area>.md`.
118
+ - date-bound memo → summarize into `today.md` ## Agent Notes.
119
+ - unclassifiable → DM the user an excerpt asking what to do; leave
120
+ the file in `inbox/` for next pass.
121
+ - After integration, move the original: (a) `PUT /api/context/agent/scratch/inbox-YYYY-MM-DD-<orig-slug>.md` with the original body, then (b) `DELETE /api/context/inbox/<file>` to remove the source. The 30-day retention on `agent/scratch/` is a convention for now — no sweeper exists yet.
122
+ - **High-risk triggers — DM for confirmation before writing:**
123
+ new project creation, wholesale overwrite of `user/profile.md`,
124
+ financial or health data with a numeric impact. The agent's own
125
+ judgment is the gate — call `POST /api/notify` with the
126
+ proposed change and wait for confirmation; don't auto-write.
127
+ - **Hard stop (never write)** — if the memo contains anything that
128
+ looks like a credential, password, API key, or private token, do
129
+ NOT write it to any context file. Log one line to ## Agent Log
130
+ (`- HH:MM [inbox] skipped <file>: secret suspected`), leave the
131
+ source file in `inbox/` for the user to handle, and move on. This
132
+ overrides the "DM then proceed" path above — see _safety.md.
133
+
134
+ ### Step 5 — Daily journal synthesis (skipped on first-run flow)
135
+ 8. Synthesize yesterday's journal from the data you already have:
136
+ - `<yesterday_agent_actions>` — previous agent-day execution rows from
137
+ SQLite. Use these for authoritative timing / result counts.
138
+ - `<yesterday_messages>` — previous agent-day non-system messages from
139
+ SQLite. Use these for conversations that never made it into
140
+ `yesterday.md`.
141
+ - `<yesterday_dm_conversation_log>` — rolling DM summaries recorded in
142
+ SQLite; useful when many message rows collapse into one thread.
143
+ - `<yesterday>` — User Schedule, User Tasks, Agent Plan, Agent Log,
144
+ Handoff sections are the primary source. The `## Agent Log` line
145
+ entries are authoritative for what the agent did; `## User Schedule`
146
+ for what was planned; conversations you handled yesterday surface
147
+ through Agent Log entries the agent wrote at the time.
148
+ - Step 4 inbox triage outcomes — in-memory from this very run.
149
+ - `<calendar_events_7d>` — reconcile against yesterday's column for
150
+ attended/skipped flags on the Schedule section.
151
+ If SQLite tags disagree with `yesterday.md`, prefer SQLite for counts,
152
+ timing, and whether an interaction/action happened at all; prefer
153
+ `yesterday.md` for curated phrasing already shown to the user.
154
+ Compose `daily/YYYY-MM-DD.md` (YYYY-MM-DD = yesterday's agent-day
155
+ date) following the **`Daily journal format spec`** policy block above.
156
+ - Write in `<settings primary_language>` (fall back to English on
157
+ unknown values). Keep technical terms in their original form.
158
+ - When `<settings vault_mode>` is `obsidian`, render project / people
159
+ references as `[[wikilink]]`s resolving to `projects/<slug>.md` or
160
+ `user/people.md#...`. When `plain`, write plain text only.
161
+ - Apply redaction from the `Redaction patterns` and `Journal export
162
+ rules` policy blocks above.
163
+ - Include frontmatter fields `date`, `weekday`, `type: daily`, `owner: agent`, `updated`,
164
+ `agent_generated: true`, `agent_last_synced_at`, `content_hash`,
165
+ `projects`, `people`, `tags`, `calendar_events`, `messages_handled`.
166
+ If the API rejects unknown fields, write the ones it accepts and
167
+ log the gap in `agent/journal.md` (Step 9).
168
+ - If `<yesterday>` frontmatter carries `no_journal_export: true`,
169
+ write the placeholder `[Skipped by user request]` as body and still
170
+ populate required frontmatter fields.
171
+ - Conflict handling: first `GET /api/context/daily/YYYY-MM-DD.md`.
172
+ - 404 → `PUT /api/context/daily/YYYY-MM-DD.md` with the full body.
173
+ - 200 → the user (or a prior run) already wrote this date. Do **not**
174
+ PUT-overwrite. Instead `PATCH /api/context/daily/YYYY-MM-DD.md`
175
+ with `mode=append_to_file` and a new section
176
+ `## Agent revision — YYYY-MM-DDTHH:MM:SS` whose body is the
177
+ synthesized journal. B-006 content-hash protection.
178
+
179
+ ### Step 6 — Generate new today.md (PUT full replace)
180
+ 9. Follow the context skill "Structure overview", "Entry formats", and
181
+ "Required sections for full replace" sections for the exact schema.
182
+ The H1 (line 1) MUST be `# <current_agent_day.date> (<current_agent_day.weekday>)`
183
+ exactly — the daemon rejects mismatches with 422. No YAML frontmatter
184
+ on today.md. Agent Plan rows MUST match
185
+ `- [ ] HH:MM <action> [work|study|personal|home] →<DM|notify|check-in|wake>`;
186
+ any other category or trigger keyword is rejected and forces a retry
187
+ on Sonnet.
188
+ Source → section mapping:
189
+ - ## User Schedule ← `<calendar_events_7d>` (filtered). Write
190
+ `- (calendar unavailable)` if `<calendar_status>` reports failure.
191
+ - ## User Tasks ← Step 1 handoff Tomorrow + Step 2 email actionables
192
+ + SoT tasks + roadmap `[today]`. Use `<active_projects>` for context.
193
+ - ## Agent Plan ← Step 2 `[notify]`/`[check]` rows plus any
194
+ proactive reminders you add (meeting pre-briefs, deadline nudges).
195
+ Every row will be registered in Step 7 — the Agent Plan contract is
196
+ defined in the skill's "User Tasks vs Agent Plan" section.
197
+ - ## Agent Notes ← Step 2 look-ahead items + date-bound memos folded
198
+ from Step 4 inbox triage.
199
+ - ## Agent Log ← initialize with
200
+ `- HH:MM Morning Routine completed (day-type: …)`.
201
+ - ## Handoff ← Step 1 "Later" items, dropping past dates.
202
+ Write `- (none)` if empty.
203
+ 10. Update `roadmap.md` only if a milestone completed or shifted today.
204
+
205
+ ### Step 7 — Register schedule
206
+ 11. Register every `## Agent Plan` row via `POST /api/schedule` (schedule skill owns the contract). This is the Agent Plan contract — every
207
+ `- [ ] HH:MM … [cat] → <trigger>` row must have exactly one matching
208
+ schedule entry.
209
+ > **Morning briefing scheduling moved.** The morning briefing is no
210
+ > longer registered here. It is a `recurring_schedules` row
211
+ > (`task_type='dm_session'`, `task_context.sub_flow='morning_briefing'`)
212
+ > created at setup completion and reconciled daily by the daemon. The
213
+ > firing session runs under the `conversational` profile via the
214
+ > `scheduled.dm.md` task-flow. See SCHEDULED-DM-IMPLEMENTATION-PLAN.md.
215
+
216
+ ### Step 7.5 — Profile-interview queue (latent, two-phase)
217
+
218
+ Use the **user-interview** skill. This step has two phases — phase (a)
219
+ ALWAYS runs (it is what keeps today.md's ## Agent Notes mirror in sync
220
+ across day boundaries, since today.md is PUT-replaced fresh each
221
+ morning); phase (b) only runs when there is no open question.
222
+
223
+ #### Step 7.5a — Mirror existing latent entries to today.md (always)
224
+
225
+ GET `agent/profile-questions.md ## In Progress`. For every entry whose
226
+ state is `latent` (NOT `asked` — those have already been answered or
227
+ will be cleaned up by the sweep), append one line to `today.md`
228
+ `## Agent Notes` using the **today** skill's "Latent profile question"
229
+ Agent Notes flavor:
230
+
231
+ ```
232
+ - Profile question (latent): <id> — wait for natural opportunity
233
+ ```
234
+
235
+ This is the only writer of the `Profile question (latent):` line.
236
+ Without it, a row
237
+ that stays latent across multiple days disappears from today.md after
238
+ day 1's PUT-replace and the DM-handler / morning-briefing opportunity
239
+ checks lose their visible cue.
240
+
241
+ #### Step 7.5b — Pick a new question (conditional)
242
+
243
+ Skip phase (b) entirely if any of:
244
+ (a) `## In Progress` is non-empty (a prior latent / asked entry is
245
+ already open — we hold to the 1-question-at-a-time invariant).
246
+ (b) The user has not sent a DM in the last 24h (no point if they're
247
+ absent).
248
+ (c) Day-type focus for `[personal]` on line 2 of `<today>` is `off`.
249
+ (d) `## Pending` is empty.
250
+
251
+ Otherwise, walk Pending rows in priority order (HIGH → MID → LOW, then
252
+ file order). For each candidate:
253
+ - If the row carries `<!-- last_attempted=YYYY-MM-DD -->` within the
254
+ last 7 days, skip — cooldown.
255
+ - GET `/api/profile-questions/slot-filled?path=<target>&section=<section?>&anchor=<anchor?>`
256
+ for the row. If `filled: true`, the slot was filled since the last
257
+ sweep — tick the row `[ ]` → `[x]` (read-rebuild + replace), append
258
+ `- [x] <today> → <id> (reconciled:morning)` to `## Answered`,
259
+ continue to the next candidate.
260
+ - Otherwise this is the chosen row. Stop walking.
261
+
262
+ If a row was chosen:
263
+
264
+ 1. PATCH `agent/profile-questions.md ## In Progress` (read-rebuild +
265
+ replace) — add a single entry. The `since=<today>` field is
266
+ load-bearing for the evening sweep's 3-day fallback computation:
267
+ ```
268
+ - <id> :: state=latent :: since=<today>
269
+ ```
270
+ 2. PATCH `today.md ## Agent Notes` (mode=append) — same flavor as
271
+ phase (a):
272
+ ```
273
+ - Profile question (latent): <id> — wait for natural opportunity
274
+ ```
275
+
276
+ **Do NOT register a `POST /api/schedule` for this row.** Latent rows
277
+ are NOT scheduled DMs — they wait for a natural opportunity (DM topic
278
+ match or morning briefing piggyback). The fallback DM path is owned by
279
+ the evening sweep (Operation 5B), not the morning routine.
280
+
281
+ ### Step 8 — Extension checks from routines/morning.md
282
+ 12. The `Morning routine checks` policy block above is the user-editable
283
+ extension surface. Execute any check listed there that is **not
284
+ already covered by Steps 1-7**. User-added entries typically carry an
285
+ `**Added: YYYY-MM-DD by user via DM**` line — those are your target.
286
+
287
+ ### Step 9 — Log to agent/journal.md (English, always)
288
+ 13. Append a one-paragraph English summary to `agent/journal.md` via
289
+ `PATCH /api/context/agent/journal` with `mode=append_to_file` (this
290
+ is the only append mode that takes no `section` argument — it's
291
+ designed for append-only journals). Use this shape:
292
+ ```
293
+ ## YYYY-MM-DD morning routine
294
+ - Day-type: <weekday / weekend / focus / …>
295
+ - Journal: daily/YYYY-MM-DD.md (<N lines, M projects referenced>)
296
+ - Inbox: <N files triaged, M moved to scratch, K DM-confirmations sent>
297
+ - Checks from routines/morning.md: <list any user-added ones executed>
298
+ - Anomalies / skipped steps: <short notes or "none">
299
+ ```
300
+ Always English (B-007 §3 P6) regardless of `<settings primary_language>`.