@aitne-sh/aitne 0.1.7 → 0.1.9

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 (317) hide show
  1. package/README.md +256 -833
  2. package/agent-assets/agent-profiles/_safety.md +52 -20
  3. package/agent-assets/agent-profiles/browser-task.md +108 -0
  4. package/agent-assets/agent-profiles/conversational.md +3 -3
  5. package/agent-assets/agent-profiles/profile-importer.md +3 -3
  6. package/agent-assets/agent-profiles/routine-fetch-window.md +30 -19
  7. package/agent-assets/agent-profiles/routine.md +4 -3
  8. package/agent-assets/agents/context-index-reconcile/agent.md +52 -0
  9. package/agent-assets/agents/evening-review/agent.md +53 -0
  10. package/agent-assets/agents/hourly-check/agent.md +62 -0
  11. package/agent-assets/agents/monthly-review/agent.md +55 -0
  12. package/agent-assets/agents/morning-routine/agent.md +78 -0
  13. package/agent-assets/agents/roadmap-maintenance/agent.md +52 -0
  14. package/agent-assets/agents/skill-curation/agent.md +52 -0
  15. package/agent-assets/agents/user-profile-sweep-evening/agent.md +48 -0
  16. package/agent-assets/agents/user-profile-sweep-morning/agent.md +53 -0
  17. package/agent-assets/agents/weekly-review/agent.md +51 -0
  18. package/agent-assets/docs/concepts/agent-day.md +18 -11
  19. package/agent-assets/docs/concepts/auth-health.md +56 -10
  20. package/agent-assets/docs/concepts/backends-and-tiers.md +110 -41
  21. package/agent-assets/docs/concepts/costs-and-quotas.md +74 -19
  22. package/agent-assets/docs/concepts/delegated-mode.md +193 -75
  23. package/agent-assets/docs/concepts/memory-model.md +79 -34
  24. package/agent-assets/docs/concepts/observations.md +61 -11
  25. package/agent-assets/docs/concepts/process-keys.md +66 -17
  26. package/agent-assets/docs/concepts/routines.md +77 -32
  27. package/agent-assets/docs/concepts/safety-and-execution.md +50 -21
  28. package/agent-assets/docs/concepts/safety-model.md +62 -37
  29. package/agent-assets/docs/concepts/skills.md +38 -17
  30. package/agent-assets/docs/features/integrations/browser-history.md +195 -0
  31. package/agent-assets/docs/features/integrations/calendar.md +40 -30
  32. package/agent-assets/docs/features/integrations/git.md +20 -9
  33. package/agent-assets/docs/features/integrations/github.md +93 -35
  34. package/agent-assets/docs/features/integrations/mail.md +60 -17
  35. package/agent-assets/docs/features/integrations/notion.md +51 -11
  36. package/agent-assets/docs/features/integrations/obsidian.md +35 -7
  37. package/agent-assets/docs/features/lifestyle/git.md +45 -44
  38. package/agent-assets/docs/features/lifestyle/reading.md +50 -22
  39. package/agent-assets/docs/features/lifestyle/receipts.md +66 -21
  40. package/agent-assets/docs/features/lifestyle/travel-bookings.md +91 -14
  41. package/agent-assets/docs/features/memory-files/agent-journal.md +111 -50
  42. package/agent-assets/docs/features/memory-files/projects.md +75 -15
  43. package/agent-assets/docs/features/memory-files/roadmap.md +55 -10
  44. package/agent-assets/docs/features/memory-files/schedule.md +113 -70
  45. package/agent-assets/docs/features/memory-files/today.md +47 -21
  46. package/agent-assets/docs/features/memory-files/user-profile.md +67 -31
  47. package/agent-assets/docs/features/messaging/bang-commands.md +115 -28
  48. package/agent-assets/docs/features/messaging/dashboard-chat.md +43 -21
  49. package/agent-assets/docs/features/messaging/discord.md +46 -4
  50. package/agent-assets/docs/features/messaging/overview.md +40 -19
  51. package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +94 -27
  52. package/agent-assets/docs/features/messaging/slack.md +79 -14
  53. package/agent-assets/docs/features/messaging/telegram.md +25 -6
  54. package/agent-assets/docs/features/messaging/whatsapp.md +79 -14
  55. package/agent-assets/docs/features/operations/activity-and-conversations.md +45 -16
  56. package/agent-assets/docs/features/operations/approvals.md +53 -15
  57. package/agent-assets/docs/features/operations/backend-routing.md +75 -16
  58. package/agent-assets/docs/features/operations/cost-tracking.md +90 -17
  59. package/agent-assets/docs/features/operations/managed-chromium.md +221 -0
  60. package/agent-assets/docs/features/operations/notifications.md +58 -11
  61. package/agent-assets/docs/features/operations/quiet-hours.md +63 -40
  62. package/agent-assets/docs/features/operations/schedule-approaching.md +59 -16
  63. package/agent-assets/docs/features/routines/custom-routines.md +97 -23
  64. package/agent-assets/docs/features/routines/evening-review.md +75 -22
  65. package/agent-assets/docs/features/routines/hourly-check.md +150 -30
  66. package/agent-assets/docs/features/routines/morning-routine.md +60 -33
  67. package/agent-assets/docs/features/routines/weekly-review.md +65 -20
  68. package/agent-assets/docs/features/wiki/commands.md +37 -16
  69. package/agent-assets/docs/features/wiki/cost-and-approval.md +240 -0
  70. package/agent-assets/docs/features/wiki/dashboard.md +255 -0
  71. package/agent-assets/docs/features/wiki/overview.md +80 -12
  72. package/agent-assets/docs/features/wiki/search.md +248 -0
  73. package/agent-assets/docs/features/wiki/workspaces.md +254 -0
  74. package/agent-assets/docs/getting-started/01-what-is-this.md +64 -32
  75. package/agent-assets/docs/getting-started/02-first-steps.md +28 -10
  76. package/agent-assets/docs/getting-started/03-what-can-this-do.md +42 -21
  77. package/agent-assets/docs/getting-started/04-first-day.md +52 -20
  78. package/agent-assets/docs/glossary.md +285 -21
  79. package/agent-assets/docs/guides/add-a-custom-routine.md +74 -22
  80. package/agent-assets/docs/guides/backup-and-restore.md +92 -14
  81. package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +62 -25
  82. package/agent-assets/docs/guides/build-your-wiki.md +33 -6
  83. package/agent-assets/docs/guides/change-which-model-handles-x.md +70 -9
  84. package/agent-assets/docs/guides/connect-a-new-mail-account.md +80 -15
  85. package/agent-assets/docs/guides/explore-with-trace-and-connect.md +32 -9
  86. package/agent-assets/docs/guides/import-knowledge-file.md +60 -39
  87. package/agent-assets/docs/guides/install-and-run.md +64 -19
  88. package/agent-assets/docs/guides/maintain-wiki-health.md +41 -10
  89. package/agent-assets/docs/guides/migrate-machines.md +86 -18
  90. package/agent-assets/docs/guides/multiple-wikis-for-multiple-domains.md +119 -59
  91. package/agent-assets/docs/guides/pause-the-agent.md +71 -22
  92. package/agent-assets/docs/guides/reinstall-cleanly.md +102 -17
  93. package/agent-assets/docs/guides/setup-wizard.md +126 -56
  94. package/agent-assets/docs/guides/switch-default-backend.md +72 -17
  95. package/agent-assets/docs/guides/use-an-existing-obsidian-vault.md +31 -10
  96. package/agent-assets/docs/reference/api.md +162 -23
  97. package/agent-assets/docs/reference/cli-commands.md +55 -15
  98. package/agent-assets/docs/reference/config.md +246 -39
  99. package/agent-assets/docs/reference/disallowed-tools.md +42 -10
  100. package/agent-assets/docs/reference/keyboard-shortcuts.md +47 -10
  101. package/agent-assets/docs/reference/knowledge-layout.md +620 -0
  102. package/agent-assets/docs/reference/process-keys.md +126 -20
  103. package/agent-assets/docs/reference/skills.md +62 -18
  104. package/agent-assets/docs/troubleshooting/auth-failed.md +53 -19
  105. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +96 -22
  106. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +94 -20
  107. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +77 -22
  108. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +87 -22
  109. package/agent-assets/docs/troubleshooting/observation-not-detected.md +85 -21
  110. package/agent-assets/docs/troubleshooting/quota-exhausted.md +36 -6
  111. package/agent-assets/docs/troubleshooting/wiki-ingest-full-blocked.md +128 -51
  112. package/agent-assets/docs/troubleshooting/wiki-write-failed.md +33 -11
  113. package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +1 -1
  114. package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +1 -1
  115. package/agent-assets/optimizer-skills/skill-curation/SKILL.md +2 -2
  116. package/agent-assets/sandbox/linux/aitne-chromium.apparmor +91 -0
  117. package/agent-assets/sandbox/macos/aitne-chromium.sb +156 -0
  118. package/agent-assets/skills/agent-actions/SKILL.md +122 -0
  119. package/agent-assets/skills/agent-create/SKILL.md +149 -0
  120. package/agent-assets/skills/attach/SKILL.md +3 -4
  121. package/agent-assets/skills/browser-history/SKILL.md +198 -0
  122. package/agent-assets/skills/browser-history-respond/SKILL.md +106 -0
  123. package/agent-assets/skills/browser-task/SKILL.md +169 -0
  124. package/agent-assets/skills/context/SKILL.md +45 -463
  125. package/agent-assets/skills/context/curation.json +2 -2
  126. package/agent-assets/skills/context/references/api.md +232 -0
  127. package/agent-assets/skills/context/references/required-frontmatter.md +73 -0
  128. package/agent-assets/skills/context/references/snapshot-files.md +103 -0
  129. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +4 -4
  130. package/agent-assets/skills/docs-search/SKILL.md +17 -16
  131. package/agent-assets/skills/external-services/SKILL.delegated.claude.md +14 -26
  132. package/agent-assets/skills/external-services/SKILL.delegated.codex.md +14 -26
  133. package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +14 -26
  134. package/agent-assets/skills/external-services/SKILL.md +9 -262
  135. package/agent-assets/skills/external-services/SKILL.native.claude.md +6 -7
  136. package/agent-assets/skills/external-services/SKILL.native.codex.md +8 -9
  137. package/agent-assets/skills/external-services/SKILL.native.gemini.md +5 -6
  138. package/agent-assets/skills/external-services/references/calendar-apple.md +97 -0
  139. package/agent-assets/skills/external-services/references/calendar-google.md +72 -0
  140. package/agent-assets/skills/external-services/references/calendar-outlook.md +36 -0
  141. package/agent-assets/skills/external-services/references/github.md +17 -0
  142. package/agent-assets/skills/external-services/references/obsidian.md +49 -0
  143. package/agent-assets/skills/external-services/references/skills-crud.md +27 -0
  144. package/agent-assets/skills/gmail-lifestyle/SKILL.md +151 -0
  145. package/agent-assets/skills/gmail-lifestyle/references/receipts-api.md +93 -0
  146. package/agent-assets/skills/gmail-lifestyle/references/travel-bookings-api.md +75 -0
  147. package/agent-assets/skills/mail/SKILL.delegated.claude.md +15 -6
  148. package/agent-assets/skills/mail/SKILL.delegated.codex.md +9 -5
  149. package/agent-assets/skills/mail/SKILL.delegated.gemini.md +9 -5
  150. package/agent-assets/skills/mail/SKILL.md +9 -114
  151. package/agent-assets/skills/mail/SKILL.native.claude.md +1 -1
  152. package/agent-assets/skills/mail/SKILL.native.codex.md +1 -1
  153. package/agent-assets/skills/mail/SKILL.native.gemini.md +1 -1
  154. package/agent-assets/skills/mail/references/api.md +110 -0
  155. package/agent-assets/skills/mail/references/examples.md +70 -0
  156. package/agent-assets/skills/mail/references/providers.md +8 -8
  157. package/agent-assets/skills/managed-tasks/SKILL.md +472 -0
  158. package/agent-assets/skills/managed-tasks/references/errors.md +73 -0
  159. package/agent-assets/skills/managed-tasks/references/output-path.md +75 -0
  160. package/agent-assets/skills/managed-tasks/references/recurrence-rule.md +86 -0
  161. package/agent-assets/skills/management-policy/SKILL.md +54 -125
  162. package/agent-assets/skills/management-policy/curation.json +1 -1
  163. package/agent-assets/skills/management-policy/references/policy-workflow.md +101 -0
  164. package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +1 -1
  165. package/agent-assets/skills/notify/SKILL.md +10 -82
  166. package/agent-assets/skills/notify/references/priority.md +65 -0
  167. package/agent-assets/skills/notion/SKILL.delegated.claude.md +2 -2
  168. package/agent-assets/skills/notion/SKILL.delegated.codex.md +2 -2
  169. package/agent-assets/skills/notion/SKILL.delegated.gemini.md +2 -2
  170. package/agent-assets/skills/notion/SKILL.md +6 -10
  171. package/agent-assets/skills/notion/SKILL.native.claude.md +11 -8
  172. package/agent-assets/skills/notion/SKILL.native.codex.md +10 -6
  173. package/agent-assets/skills/notion/SKILL.native.gemini.md +10 -6
  174. package/agent-assets/skills/observations/SKILL.md +25 -14
  175. package/agent-assets/skills/project-doc/SKILL.md +2 -6
  176. package/agent-assets/skills/project-doc/curation.json +3 -3
  177. package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +7 -4
  178. package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +3 -3
  179. package/agent-assets/skills/reading/SKILL.md +12 -2
  180. package/agent-assets/skills/reading/references/reading-taste.md +2 -2
  181. package/agent-assets/skills/roadmap/SKILL.md +43 -141
  182. package/agent-assets/skills/roadmap/curation.json +1 -1
  183. package/agent-assets/skills/roadmap/references/api.md +100 -0
  184. package/agent-assets/skills/roadmap/references/cross-check.md +80 -0
  185. package/agent-assets/skills/roadmap/references/migration.md +56 -0
  186. package/agent-assets/skills/roadmap/references/preparation-timeline.md +2 -2
  187. package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +1 -1
  188. package/agent-assets/skills/schedule/SKILL.md +76 -104
  189. package/agent-assets/skills/schedule/references/batch.md +93 -0
  190. package/agent-assets/skills/schedule/references/errors.md +217 -0
  191. package/agent-assets/skills/schedule/references/model-selection.md +96 -0
  192. package/agent-assets/skills/schedule/references/recurrence-rule.md +86 -0
  193. package/agent-assets/skills/scheduled-managed-task/SKILL.md +59 -51
  194. package/agent-assets/skills/today/SKILL.md +32 -62
  195. package/agent-assets/skills/today/curation.json +3 -3
  196. package/agent-assets/skills/today/references/agent-plan-lifecycle.md +114 -0
  197. package/agent-assets/skills/today/seeds/section-shape.seed.json +1 -1
  198. package/agent-assets/skills/user-interview/SKILL.md +23 -67
  199. package/agent-assets/skills/user-interview/references/op-briefing.md +51 -0
  200. package/agent-assets/skills/user-interview/references/op-morning.md +59 -0
  201. package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +9 -1
  202. package/agent-assets/skills/user-profile/SKILL.md +54 -74
  203. package/agent-assets/skills/user-profile/curation.json +2 -2
  204. package/agent-assets/skills/user-profile/references/character-preferences.md +83 -0
  205. package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +8 -8
  206. package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +30 -2
  207. package/agent-assets/skills/wiki/wiki-ask/SKILL.md +0 -1
  208. package/agent-assets/skills/wiki/wiki-compile/SKILL.md +4 -5
  209. package/agent-assets/skills/wiki/wiki-connect/SKILL.md +0 -1
  210. package/agent-assets/skills/wiki/wiki-graduate/SKILL.md +0 -1
  211. package/agent-assets/skills/wiki/wiki-ingest/SKILL.md +0 -1
  212. package/agent-assets/skills/wiki/wiki-lint/SKILL.md +0 -1
  213. package/agent-assets/skills/wiki/wiki-trace/SKILL.md +0 -1
  214. package/agent-assets/skills/wiki/wiki-vault-rules/SKILL.md +0 -1
  215. package/agent-assets/system-prompts/routine-fetch-window.md +78 -0
  216. package/agent-assets/system-prompts/skill-index-instruction.md +26 -0
  217. package/agent-assets/task-flows/_partials/calendar-acquire.google_calendar.md +20 -11
  218. package/agent-assets/task-flows/_partials/calendar-acquire.outlook_calendar.md +18 -9
  219. package/agent-assets/task-flows/_partials/capture-user-info.md +24 -0
  220. package/agent-assets/task-flows/_partials/confirm-subflow.md +68 -0
  221. package/agent-assets/task-flows/_partials/dm-intent.long-horizon.md +35 -0
  222. package/agent-assets/task-flows/_partials/dm-intent.project.md +391 -0
  223. package/agent-assets/task-flows/_partials/mail-acquire.gmail.md +20 -11
  224. package/agent-assets/task-flows/_partials/mail-acquire.outlook_mail.md +18 -9
  225. package/agent-assets/task-flows/_partials/notion-acquire.notion.md +26 -15
  226. package/agent-assets/task-flows/browser_task.md +84 -0
  227. package/agent-assets/task-flows/github.assigned.md +1 -1
  228. package/agent-assets/task-flows/github.pull_request.review_requested.md +2 -2
  229. package/agent-assets/task-flows/github.workflow_run.failed.md +2 -2
  230. package/agent-assets/task-flows/knowledge.import.md +15 -15
  231. package/agent-assets/task-flows/message.received.dm.md +20 -17
  232. package/agent-assets/task-flows/message.received.dm_first.md +11 -15
  233. package/agent-assets/task-flows/routine.custom.md +6 -4
  234. package/agent-assets/task-flows/routine.evening_review.md +46 -170
  235. package/agent-assets/task-flows/routine.fetch_window.md +19 -14
  236. package/agent-assets/task-flows/routine.hourly_check.md +27 -15
  237. package/agent-assets/task-flows/routine.hourly_check.triage.md +1 -1
  238. package/agent-assets/task-flows/routine.monthly_review.md +67 -25
  239. package/agent-assets/task-flows/routine.morning_routine_journal.md +135 -0
  240. package/agent-assets/task-flows/routine.morning_routine_today.md +673 -0
  241. package/agent-assets/task-flows/routine.research_cluster_update.md +35 -0
  242. package/agent-assets/task-flows/routine.research_dispatch.md +38 -0
  243. package/agent-assets/task-flows/routine.research_offer_dm.md +125 -0
  244. package/agent-assets/task-flows/routine.research_wiki_summary.md +53 -0
  245. package/agent-assets/task-flows/routine.roadmap_refresh.md +68 -23
  246. package/agent-assets/task-flows/routine.today_refresh.md +4 -4
  247. package/agent-assets/task-flows/routine.user_profile_sweep.md +19 -20
  248. package/agent-assets/task-flows/routine.weekly_review.md +370 -86
  249. package/agent-assets/task-flows/schedule.approaching.md +0 -1
  250. package/agent-assets/task-flows/scheduled.dm.md +13 -13
  251. package/agent-assets/task-flows/scheduled.task.md +9 -9
  252. package/agent-assets/task-flows/setup.initial.md +171 -251
  253. package/agent-assets/task-flows/setup.update.md +2 -2
  254. package/agent-assets/task-flows/wiki.ingest_url.md +1 -1
  255. package/agent-assets/templates/README.md +27 -20
  256. package/agent-assets/templates/_index.md +42 -26
  257. package/agent-assets/templates/_manifest.json +34 -99
  258. package/agent-assets/templates/{user → identity}/_index.md +1 -1
  259. package/agent-assets/templates/identity/expertise.md +9 -0
  260. package/agent-assets/templates/identity/goals.md +9 -0
  261. package/agent-assets/templates/identity/people.md +13 -0
  262. package/agent-assets/templates/identity/personal.md +9 -0
  263. package/agent-assets/templates/{user → identity}/profile.md +2 -2
  264. package/agent-assets/templates/identity/work.md +9 -0
  265. package/agent-assets/templates/{dossiers → knowledge/dossiers}/_index.md +2 -2
  266. package/agent-assets/templates/{projects → plans/projects}/_active.base +1 -1
  267. package/agent-assets/templates/policies/_index.md +21 -0
  268. package/agent-assets/templates/{rules → policies}/journal-export.md +1 -1
  269. package/agent-assets/templates/policies/journal-format.md +168 -0
  270. package/agent-assets/templates/{rules/policies → policies/management-captures}/_index.md +2 -2
  271. package/agent-assets/templates/{rules → policies}/management.md +3 -3
  272. package/agent-assets/templates/{rules → policies}/mcp.md +1 -1
  273. package/agent-assets/templates/{rules → policies}/redaction.md +1 -1
  274. package/agent-assets/templates/{routines → policies/routines}/_index.md +1 -1
  275. package/agent-assets/templates/{routines → policies/routines}/evening.md +2 -2
  276. package/agent-assets/templates/{routines → policies/routines}/hourly.md +1 -1
  277. package/agent-assets/templates/{routines → policies/routines}/monthly.md +2 -2
  278. package/bin/aitne.mjs +21 -5
  279. package/package.json +5 -4
  280. package/scripts/commands/doctor.mjs +63 -5
  281. package/scripts/commands/run-now.mjs +187 -0
  282. package/scripts/commands/verify.mjs +264 -0
  283. package/scripts/lib/ports.d.mts +27 -0
  284. package/scripts/lib/ports.mjs +36 -0
  285. package/scripts/lib/read-api-token.mjs +176 -0
  286. package/scripts/start.mjs +2 -1
  287. package/agent-assets/docs/features/lifestyle/travel-time.md +0 -52
  288. package/agent-assets/docs/features/routines/monthly-review.md +0 -65
  289. package/agent-assets/skills/management-task-modify/SKILL.md +0 -203
  290. package/agent-assets/skills/management-task-register/SKILL.md +0 -330
  291. package/agent-assets/skills/management-task-stop/SKILL.md +0 -166
  292. package/agent-assets/skills/receipts/SKILL.md +0 -134
  293. package/agent-assets/skills/travel/SKILL.md +0 -132
  294. package/agent-assets/skills/travel-time/SKILL.md +0 -158
  295. package/agent-assets/task-flows/routine.morning_routine.md +0 -322
  296. package/agent-assets/task-flows/routine.morning_routine_initial.md +0 -204
  297. package/agent-assets/templates/context-index.md +0 -42
  298. package/agent-assets/templates/rules/_index.md +0 -19
  299. package/agent-assets/templates/rules/journal-format.md +0 -61
  300. package/agent-assets/templates/user/expertise.md +0 -7
  301. package/agent-assets/templates/user/goals.md +0 -7
  302. package/agent-assets/templates/user/people.md +0 -7
  303. package/agent-assets/templates/user/personal.md +0 -7
  304. package/agent-assets/templates/user/work.md +0 -7
  305. /package/agent-assets/templates/{agent/journal.md → journal/agent.md} +0 -0
  306. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/evening.md +0 -0
  307. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/hourly.md +0 -0
  308. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/monthly.md +0 -0
  309. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/morning.md +0 -0
  310. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/roadmap.md +0 -0
  311. /package/agent-assets/templates/{dossiers → knowledge/dossiers}/weekly.md +0 -0
  312. /package/agent-assets/templates/{projects → plans/projects}/_index.md +0 -0
  313. /package/agent-assets/templates/{roadmap.md → plans/roadmap.md} +0 -0
  314. /package/agent-assets/templates/{routines → policies/routines}/morning.md +0 -0
  315. /package/agent-assets/templates/{routines → policies/routines}/weekly.md +0 -0
  316. /package/agent-assets/templates/{agent → state}/profile-questions.md +0 -0
  317. /package/agent-assets/templates/{today.md → state/today.md} +0 -0
@@ -0,0 +1,96 @@
1
+ ---
2
+ kind: reference
3
+ name: model-selection
4
+ description: Tier vs model selection for schedule rows + `GET /api/schedule/options` discovery endpoint. Mutual-exclusion rules, legacy alias rewrite, composite-form disambiguator.
5
+ ---
6
+
7
+ # Tier / Model selection
8
+
9
+ `tier` is the backend-neutral cost knob — **prefer it**. `model` pins
10
+ a specific registered model id when the row must run against a
11
+ particular backend (e.g. a routine that depends on Opus reasoning
12
+ even after `/settings/models` re-routes the process key). The two are
13
+ **mutually exclusive on a single row** — passing both returns
14
+ `schedule.tier_and_model_conflict` (no "tier wins" precedence).
15
+
16
+ | `tier` | Class | When |
17
+ |---|---|---|
18
+ | `"lite"` | Haiku | hourly polling / health checks (e.g. docker `ps` summary) |
19
+ | `"medium"` | Sonnet | lock against future `/settings/models` re-routes |
20
+ | `"high"` | Opus | one-off generative work driving user-visible output |
21
+
22
+ `model` accepts:
23
+
24
+ - **Legacy aliases** — `"sonnet"` / `"opus"`. Auto-rewritten at the
25
+ route to `tier:"medium"` / `tier:"high"`; the alias is not stored
26
+ verbatim.
27
+ - **Registered model ids** — any id from `MODEL_REGISTRY` across the
28
+ four backends. Examples: `claude-opus-4-8`, `claude-sonnet-4-6`,
29
+ `claude-haiku-4-5-20251001`, `gpt-5.4`, `gemini-3.1-pro-preview`.
30
+ The row persists `(model, backend_id)` together so the dispatcher
31
+ honors the pin at fire time.
32
+ - **Composite `<backendId>/<modelId>`** — disambiguator for a future
33
+ registry that has the same model id under multiple backends (today
34
+ unreachable but accepted). The prefix MUST be one of `claude` /
35
+ `codex` / `gemini` / `opencode`; opencode model ids like
36
+ `anthropic/claude-opus-4-8` are NOT composites and fall through to
37
+ the cross-backend scan.
38
+
39
+ Unknown / ambiguous / deprecated model tokens surface through the
40
+ error envelope's `validValues` field — read it instead of guessing.
41
+ The full code list lives in `references/errors.md`.
42
+
43
+ ## PATCH semantics — tier ↔ model swap
44
+
45
+ A row carries at most one pin at rest. On PATCH:
46
+
47
+ - Pass `null` to clear one and a concrete value to set the other in
48
+ the same request — that is the documented form for swapping a
49
+ tier-pinned row to a model-pinned row (and vice versa).
50
+ - Setting a registered `model` token also clears any prior
51
+ `tier_override` automatically; setting `tier` does not auto-clear
52
+ `model` — pair the change with `"model": null` when the intent is
53
+ to swap.
54
+ - Setting a legacy alias (`sonnet` / `opus`) on PATCH is rewritten to
55
+ `tier:"medium"` / `tier:"high"`; the alias is never stored verbatim.
56
+
57
+ ## Discovery — `GET /api/schedule/options`
58
+
59
+ Read-only one-stop endpoint that returns every value the daemon will
60
+ accept right now: registered models per backend, model aliases,
61
+ allowed tiers, recurrence frequencies, `daysOfWeek` map, hourly /
62
+ monthly bounds (`intervalHours` 1..23, `minuteOfHour` 0..59,
63
+ `onMissingDay` default), and the operator's configured timezone.
64
+ Fetch once per cold session before composing tricky schedules; the
65
+ error envelope also cites this endpoint via `docsUrl` so you can
66
+ recover after a 400.
67
+
68
+ ```bash
69
+ curl -s http://localhost:8321/api/schedule/options
70
+ ```
71
+
72
+ Response shape:
73
+
74
+ ```jsonc
75
+ {
76
+ "tiers": ["lite", "medium", "high"],
77
+ "modelAliases": { "sonnet": "medium", "opus": "high" },
78
+ "models": {
79
+ "claude": [{ "id": "claude-opus-4-8", "tier": "high", "deprecated": false }, ...],
80
+ "codex": [...],
81
+ "gemini": [...],
82
+ "opencode": [...]
83
+ },
84
+ "frequencies": ["hourly", "daily", "weekly", "monthly"],
85
+ "daysOfWeek": { "0": "Sun", "1": "Mon", ..., "6": "Sat" },
86
+ "recurrence": {
87
+ "intervalHours": { "min": 1, "max": 23 },
88
+ "minuteOfHour": { "min": 0, "max": 59 },
89
+ "daysOfMonth": { "min": 1, "max": 31 },
90
+ "onMissingDay": { "values": ["skip", "lastDayOfMonth"], "default": "lastDayOfMonth" }
91
+ },
92
+ "timeFormat": "HH:MM (24h)",
93
+ "timezoneExample": "Asia/Tokyo",
94
+ "defaults": { "timezone": "<operator's configured primary timezone>" }
95
+ }
96
+ ```
@@ -0,0 +1,86 @@
1
+ ---
2
+ kind: reference
3
+ name: recurrence-rule
4
+ description: recurrenceRule grammar — hourly / daily / weekly / monthly. Engine accepts all four; the managed-tasks consumer specifically refuses sub-daily for app-fetch correctness (template below).
5
+ ---
6
+
7
+ # recurrenceRule grammar
8
+
9
+ The daemon's recurrence engine accepts four frequencies: `hourly`,
10
+ `daily`, `weekly`, `monthly`. Each frequency requires its own set of
11
+ fields and rejects fields that don't apply — the daemon's Zod
12
+ refinements return a `schedule.frequency_field_mismatch` issue (with
13
+ the offending field path) when the shape disagrees with the chosen
14
+ frequency. Pre-validate to save a round-trip.
15
+
16
+ Times are `HH:MM` 24-hour local; `timezone` is IANA (auto-fills from
17
+ daemon config when omitted, but explicit is safer so a roaming laptop
18
+ does not surprise the user).
19
+
20
+ ## Engine — per-frequency field rules
21
+
22
+ | `frequency` | Required | Allowed | Forbidden |
23
+ |---|---|---|---|
24
+ | `hourly` | — | `intervalHours` (1..23, default 1), `minuteOfHour` (0..59, default 0), `timezone` | `time`, `daysOfWeek`, `daysOfMonth`, `onMissingDay` |
25
+ | `daily` | `time` | `timezone` | `intervalHours`, `minuteOfHour`, `daysOfWeek`, `daysOfMonth`, `onMissingDay` |
26
+ | `weekly` | `time`, `daysOfWeek` | `timezone` | `intervalHours`, `minuteOfHour`, `daysOfMonth`, `onMissingDay` |
27
+ | `monthly` | `time`, `daysOfMonth` | `timezone`, `onMissingDay` (default `lastDayOfMonth`) | `intervalHours`, `minuteOfHour`, `daysOfWeek` |
28
+
29
+ - `daysOfWeek` is `0=Sun..6=Sat`; 1..7 distinct entries, dupes rejected.
30
+ - `daysOfMonth` is `1..31`; 1..31 distinct entries, dupes rejected.
31
+ Days 29-31 may not exist in a given month — see `onMissingDay`.
32
+ - `onMissingDay`: `"skip"` (don't fire that month) or
33
+ `"lastDayOfMonth"` (fire on the actual last day, preserving the
34
+ pre-redesign clamp behavior). Default `"lastDayOfMonth"` for
35
+ back-compat. The engine also de-duplicates calendar dates that
36
+ collapse to the same fire (e.g. `[28,31]` in non-leap Feb with
37
+ `"lastDayOfMonth"` fires Feb 28 once, not twice).
38
+ - `intervalHours=N` fires when `(localHour % N) == 0` at
39
+ `minuteOfHour` local, anchored at midnight in the rule's
40
+ `timezone`.
41
+
42
+ ## Mapping table
43
+
44
+ | User said | `cadence` | `recurrenceRule` |
45
+ |---|---|---|
46
+ | every hour | `hourly :00 (UTC)` | `{frequency:"hourly"}` |
47
+ | every 2 hours at :30 | `hourly /2 :30 (UTC)` | `{frequency:"hourly", intervalHours:2, minuteOfHour:30}` |
48
+ | every day at 10am (Asia/Tokyo) | `daily 10:00 (Asia/Tokyo)` | `{frequency:"daily", time:"10:00", timezone:"Asia/Tokyo"}` |
49
+ | every Monday 9am | `weekly Mon 09:00` | `{frequency:"weekly", time:"09:00", timezone:<user tz>, daysOfWeek:[1]}` |
50
+ | every weekday at 8am | `weekdays 08:00` | `{frequency:"weekly", time:"08:00", timezone:<user tz>, daysOfWeek:[1,2,3,4,5]}` |
51
+ | 1st of every month at noon | `monthly day 1 12:00` | `{frequency:"monthly", time:"12:00", timezone:<user tz>, daysOfMonth:[1]}` |
52
+ | 25th of every month at 21:00 | `monthly day 25 21:00` | `{frequency:"monthly", time:"21:00", timezone:<user tz>, daysOfMonth:[25]}` |
53
+ | last day of every month at 21:00 | `monthly last 21:00` | `{frequency:"monthly", time:"21:00", timezone:<user tz>, daysOfMonth:[31], onMissingDay:"lastDayOfMonth"}` |
54
+ | every 5 minutes | _not representable_ | _refuse — sub-hour cadences are not supported_ |
55
+
56
+ ## Consumer-specific refusal — managed-tasks only
57
+
58
+ The managed-tasks skill (`mt_<n>` rows) refuses sub-daily cadences
59
+ because app-fetch correctness requires a daily-or-coarser window to
60
+ amortise rate limits and to map cleanly onto the entity-mirror's
61
+ daily granularity. Schedule callers (`/api/schedule`,
62
+ `/api/recurring-schedules`) have no such constraint and may use any
63
+ of the four frequencies the engine accepts.
64
+
65
+ ### managed-tasks sub-daily refusal — DM template
66
+
67
+ > Managed tasks only support daily, weekly, or monthly cadences.
68
+ > "every hour" / "every 5 minutes" is too tight for a recurring app
69
+ > fetch — pick `daily` or coarser. (If you want a daemon-internal
70
+ > hourly check, use `/api/recurring-schedules` via the `schedule`
71
+ > skill.)
72
+
73
+ Same template applies to "every 5 minutes", "every 30 minutes",
74
+ "every 2 hours", etc. when the registering surface is managed-tasks.
75
+
76
+ ## Cadence string vs structured rule
77
+
78
+ Always send both `cadence` (human-readable, rendered in
79
+ `policies/management.md` §B) and `recurrenceRule` (structured, what the
80
+ scheduler executes). They must agree — if they drift, the rendered
81
+ file misleads the user about what the scheduler will actually do.
82
+
83
+ When the user modifies just the time (`"9am instead of 10am"`),
84
+ send the new `cadence` and new `recurrenceRule` together in the same
85
+ PATCH so the §B label matches the executable schedule in one
86
+ transition.
@@ -1,20 +1,18 @@
1
1
  ---
2
2
  name: scheduled-managed-task
3
- description: Run an `mt_<n>` managed task at its scheduled slot — pick a tool, fetch since last run, resolve to entity via §7.6, merge into `<domain>/<type-plural>/<slug>.md`. Trigger when `task_context.mt_id` matches `mt_<n>`; `task_context.adhoc === true` means run-now.
4
- when_to_use: A `scheduled.task` session with `task_context.mt_id` matching `mt_<n>`; `task_context.adhoc === true` marks on-demand pulls. SKIP for regular scheduled tasks, DM-tone scheduled sessions (`scheduled.dm`), or one-off reminder delivery.
3
+ description: A `scheduled.task` session with `task_context.mt_id` matching `mt_<n>`; `task_context.adhoc === true` marks on-demand pulls. SKIP for regular scheduled tasks, DM-tone scheduled sessions (`scheduled.dm`), or one-off reminder delivery.
5
4
  allowed-tools:
6
5
  - Bash(curl *)
7
- - Bash(jq *)
8
6
  - Read
9
7
  ---
10
8
 
11
9
  # Scheduled Managed-Task Run
12
10
 
13
11
  This skill is the **scheduled execution** half of the management
14
- registry. The DM-side counterparts
15
- `management-task-register` / `-modify` / `-stop` — own the row's
16
- lifecycle. This skill is what fires every cron slot to actually do
17
- the work.
12
+ registry. The DM-side counterpart the `managed-tasks` skill
13
+ (`## Register` / `## Modify` / `## Stop` / `## Run once`)owns the
14
+ row's lifecycle. This skill is what fires every cron slot to actually
15
+ do the work.
18
16
 
19
17
  ## When this skill activates
20
18
 
@@ -72,8 +70,8 @@ records the orphan firing.
72
70
 
73
71
  ### Step 2 — Select tool (LLM judgment, fresh each run)
74
72
 
75
- Same rule as `management-task-register` Step 3: enumerate the
76
- tools available to this session and pick by capability for
73
+ Same rule as the `managed-tasks` skill's `## Register` Step 3:
74
+ enumerate the tools available to this session and pick by capability for
77
75
  `item.app`. The user's prior choice (when surfaced as a hint in
78
76
  `task_context.lastToolChoice` by an earlier run) is a **hint**, not
79
77
  a binding — if it no longer exists in this session (the user
@@ -146,9 +144,9 @@ output_path = "finance/receipts/" → domain=finance, type=receipt
146
144
  ```
147
145
 
148
146
  If `output_path` is null (first run), pick the best `(domain, type)`
149
- from the data shape using the same prior table from
150
- `management-task-register` Step 4a. After this run, write the
151
- chosen path back to the row (Step 5b) so subsequent runs converge.
147
+ from the data shape using the same prior table from the `managed-tasks`
148
+ skill `## Register` Step 4a. After this run, write the chosen path back
149
+ to the row (Step 5b) so subsequent runs converge.
152
150
 
153
151
  Slug: `<YYYY-MM-DD>-<sanitized-title>`. Sanitization rules:
154
152
  lowercase, ASCII-fold, replace `[^a-z0-9-]+` with `-`, collapse
@@ -177,39 +175,49 @@ runs. The (`section`, `mode`, `content`, `cutoff`, `maxEntries`)
177
175
  shape is the contract today — see `contextPatchSchema` in
178
176
  `packages/shared/src/schemas.ts`.
179
177
 
180
- **Source-id capture (write the `external_id` into the body lines):**
181
- the entity-mirror watcher (P5) reparses the file's frontmatter on
182
- change, so the dedup contract in §7.6 hinges on the upstream id
183
- landing in **frontmatter**, not just the body. Until the entity-mirror
184
- reconciler ships AND the context API gains a `frontmatter*` patch
185
- mode for `<domain>/<type-plural>/*` files, do this:
186
-
187
- 1. Always include `- external_id: <id>` on its own line in the
188
- appended `## <App> Notes` body so a future reconciler-rebuild can
189
- recover the binding from prose.
190
- 2. Track the binding in the §B "Recently changed" path — the
191
- `agent_actions.management_task.run_recorded` row's `detail` is
192
- structured and survives even when the file body doesn't reflect
193
- the binding cleanly.
194
-
195
- > **Implementation gap to flag** (Phase 5 / extended Phase 3): the
196
- > context PATCH route does not currently:
197
- > - allow writes under `<domain>/<type-plural>/*` (no entry in
198
- > `CONTEXT_WRITE_PERMISSIONS`), so this PATCH returns `403
199
- > forbidden` until the whitelist is widened, and
200
- > - expose a `frontmatterMerge` mode for deep-merging
201
- > `frontmatter.sources.<app>`.
202
- > Both are required by design 21 §10.4 step 4b and must land before
203
- > this Step 5a goes from "designed" to "operational". Until then,
204
- > Step 5b's audit row is the durable trace of the run — surface that
205
- > in the activity-view rather than relying on the entity body.
206
-
207
- If the entity file does not previously exist, today's API requires a
208
- PUT with full content (the `<domain>/<type-plural>/*` write path is
209
- gated by the same whitelist note above). When the gap closes, the
210
- first PATCH must include a complete frontmatter block — `type`,
211
- `domain`, `slug`, `title`, `created`, `sources` or the daemon
212
- returns 422 against `EntitySchema`.
178
+ **Source-id capture deep-merge into frontmatter (`mode:"frontmatterMerge"`):**
179
+ the §7.6 dedup contract hinges on the upstream id landing in **frontmatter**
180
+ (`sources.<app>.external_id`) the canonical signal the entity-mirror watcher
181
+ reparses and `GET /api/entities?source=…&external_id=…` queries not just the
182
+ body. The context PATCH route exposes `mode:"frontmatterMerge"` for exactly this
183
+ (design 21 §10.4 step 4b): it deep-merges a partial frontmatter object into the
184
+ file's existing YAML (nested objects merge key-by-key; scalars/arrays replace),
185
+ so a new `<app>` source is linked without clobbering other apps' ids, other
186
+ frontmatter keys, or the body:
187
+
188
+ ```bash
189
+ curl -sS -X PATCH "http://localhost:8321/api/context/work/meetings/2026-12-04-foo-1on1" \
190
+ -H 'Content-Type: application/json' \
191
+ -d @- <<'JSON'
192
+ {
193
+ "mode": "frontmatterMerge",
194
+ "frontmatter": {
195
+ "sources": { "zoom": { "external_id": "zm_xyz789" } },
196
+ "last_synced_at": "2026-12-04T09:00:00Z"
197
+ }
198
+ }
199
+ JSON
200
+ ```
201
+
202
+ `frontmatterMerge` requires a non-empty `frontmatter` object and takes no
203
+ `section` (it never touches the body). Append the human-readable
204
+ `## <App> Notes` section in a separate `mode:"append"` / `"append_to_file"`
205
+ PATCH. Also keep Step 5b's audit row as the durable structured trace of the run.
206
+
207
+ > **Write path:** the bare `<domain>/<type-plural>/<slug>` path is alias-rewritten
208
+ > to `knowledge/entities/<domain>/<type-plural>/<slug>` by `context-vault-aliases.ts`,
209
+ > which **is** whitelisted in `CONTEXT_WRITE_PERMISSIONS` for `PUT`/`PATCH`
210
+ > (autonomous tier), so both the frontmatterMerge and the body-append PATCH
211
+ > succeed on an existing entity file. (Recognised domains: `work`, `travel`,
212
+ > `finance`, `personal`, `health`, `learning`.)
213
+
214
+ If the entity file does not previously exist, PATCH returns
215
+ `404 context.path_not_found` — today's API requires a PUT with full
216
+ content to create it first (the `<domain>/<type-plural>/*` write path
217
+ is whitelisted for both PUT and PATCH; only the file-existence rule
218
+ forces the PUT-first ordering). The creating PUT must include a
219
+ complete frontmatter block — `type`, `domain`, `slug`, `title`,
220
+ `created`, `sources` — or the daemon returns 422 against `EntitySchema`.
213
221
 
214
222
  ### Step 5b — Update the row
215
223
 
@@ -256,8 +264,8 @@ audit shape.
256
264
  If the run produced a mix of domains/types (e.g. Drive PDFs that were
257
265
  half receipts and half random docs), leave `output_path` null — let
258
266
  the next run try again. The renderer marks null-path rows in §B with
259
- an em-dash; the user can also set the path explicitly via
260
- `management-task-modify`.
267
+ an em-dash; the user can also set the path explicitly via the
268
+ `managed-tasks` skill `## Modify` flow.
261
269
 
262
270
  ### Step 6 — Three-strikes notify
263
271
 
@@ -298,7 +306,7 @@ agent keeps trying, but doesn't disappear silently.
298
306
  `scheduled.task` flow's "Output contract — your final text becomes a
299
307
  DM" applies (`scheduled.task.md`). For managed-task runs the default
300
308
  is **empty final text**: bookkeeping is invisible by design. The user
301
- sees the change reflected in `_activity/<source>.md` (auto-built) and
309
+ sees the change reflected in `state/activity/<source>.md` (auto-built) and
302
310
  `<domain>/_index.md`, not in a chat ping per fire.
303
311
 
304
312
  Exceptions:
@@ -345,7 +353,7 @@ appended `## <App> Notes` body, not as a separate DM.
345
353
  | HTTP | `error` | What to do |
346
354
  |---|---|---|
347
355
  | 400 (`/api/managed-tasks/:id/run-result`) | `invalid_id` / `validation_error` | Body shape drift — re-check field names exactly match `last_run_at` / `last_result` / `consecutive_failures` |
348
- | 403 (`/api/context/<domain>/<type-plural>/...`) | `forbidden` | Entity-domain write paths are not yet whitelisted (Phase 5 gap, §Step 5a). Skip the entity merge for this run, still record run-result, and surface a one-line warning in `last_result`. |
356
+ | 404 (`/api/context/<domain>/<type-plural>/...`) | `context.path_not_found` | The entity file does not exist yet PATCH cannot create it. Create it first with a PUT carrying full content + complete frontmatter (§Step 5a), then the merge succeeds. (Entity-domain write paths ARE whitelisted for PUT/PATCH; the prior 403 claim is obsolete.) |
349
357
  | 404 (`/api/managed-tasks/:id`) | `not_found` | Row was stopped mid-run. End the session quietly. |
350
358
  | 422 (`/api/context/...`) | `validation_error` | Frontmatter incomplete or malformed; populate all required fields and retry once |
351
359
  | 422 (`/api/managed-tasks/:id`) | `validation_error` | Path / body shape rejected; drop the offending field (typically `output_path`) and retry once with the rest |
@@ -359,7 +367,7 @@ appended `## <App> Notes` body, not as a separate DM.
359
367
  daemon owns the threshold notify, the agent emits one DM at the
360
368
  3rd consecutive failure, then stays silent until success or stop.
361
369
  - Does NOT touch the §B row's `app` or `cadence` — those are
362
- user-mutable only via `management-task-modify`.
370
+ user-mutable only via the `managed-tasks` skill `## Modify` flow.
363
371
  - Does NOT INSERT `agent_schedule` rows. The cron scheduler does.
364
372
  - Does NOT delete entity files when a tool returns "this item was
365
373
  removed upstream". Removal-from-source is recorded as a
@@ -381,7 +389,7 @@ appended `## <App> Notes` body, not as a separate DM.
381
389
  | `GET /api/entities?source=` | Step 4 bias hint (list-by-source-key) |
382
390
  | `GET /api/entities?domain=&type=&date=&q=` | Step 4.2 (tier-2 fuzzy) |
383
391
  | `GET /api/entities/by-path?path=` | Step 4 (verify before merging) |
384
- | `PATCH /api/context/<domain>/<type-plural>/<slug>` | Step 5a (gated by entity-domain write whitelistPhase 5 gap) |
392
+ | `PATCH /api/context/<domain>/<type-plural>/<slug>` | Step 5a (whitelisted PUT/PATCH; PATCH requires the file to exist PUT-create first if 404) |
385
393
  | `PATCH /api/managed-tasks/:id/run-result` | Step 5b (internal — last_run_at / last_result / consecutive_failures) |
386
394
  | `PATCH /api/managed-tasks/:id` | Step 5b output-path back-fill only |
387
395
  | `POST /api/notify` | Step 6 (only on the 3-failures-in-a-row crossing edge) |
@@ -8,10 +8,7 @@ allowed-tools:
8
8
 
9
9
  # today.md Guide
10
10
 
11
- Output language: follow `<output_language_policy>`. today.md is
12
- Policy B — the **skeleton lines listed below stay English verbatim**;
13
- bullets, narrative, and free-text fields under each H2 are written in
14
- `<settings primary_language>`. Preserve user-customized headers verbatim.
11
+ Output language: today.md is Policy B — see `<output_language_policy>`. The skeleton lines listed below stay English verbatim; bullets and narrative under each H2 are in `<settings primary_language>`.
15
12
 
16
13
  **Skeleton (do NOT translate — exact-regex-validated on PUT):**
17
14
 
@@ -26,7 +23,7 @@ bullets, narrative, and free-text fields under each H2 are written in
26
23
  `## Agent Plan`, `## Agent Notes`, `## Agent Log`, `## Handoff` —
27
24
  in this order.
28
25
 
29
- A `PUT /api/context/today` whose line 1 or line 2 fails the exact regex
26
+ A `PUT /api/context/state/today` whose line 1 or line 2 fails the exact regex
30
27
  is rejected with 400 and the daemon does NOT write the file. Translating
31
28
  any keyword on line 2 (the field labels, the `Weekday`/`Weekend` value,
32
29
  or `on`/`off`) into the user's primary language is the most common
@@ -66,9 +63,9 @@ line 1 is exactly `# 2026-04-28 (Tuesday)`. Do **not** advance the date
66
63
  because the routine is "preparing tomorrow"; the morning routine always
67
64
  prepares the agent-day in progress, not the next one.
68
65
 
69
- `PUT /api/context/today` returns 422 if line 1 disagrees with the
70
- daemon's current agent-day; the error message echoes both values so a
71
- mistake is recoverable in the same session.
66
+ `PUT /api/context/state/today` returns 400 (`error:"validation_error"`) if
67
+ line 1 disagrees with the daemon's current agent-day; the error message
68
+ echoes both values so a mistake is recoverable in the same session.
72
69
 
73
70
  today.md has **no YAML frontmatter** — the H1 must be the first byte of
74
71
  the file.
@@ -83,7 +80,7 @@ Line 2 encodes today's filter policy (field order is fixed — downstream parser
83
80
 
84
81
  Derivation (Morning Routine at 04:00):
85
82
  1. Day-of-week from `<current_time>`. Weekday = Mon–Fri, Weekend = Sat–Sun (unless user/profile.md overrides).
86
- 2. Read `user/profile.md` → ## Notification Preferences. Apply matching policy.
83
+ 2. Read `identity/profile.md` → ## Notification Preferences. Apply matching policy.
87
84
  3. No explicit policy → default: weekday = all on, weekend = work off, study on, personal on.
88
85
 
89
86
  Category → focus-dimension mapping:
@@ -143,28 +140,16 @@ Violations: row without schedule → silently never fires. Schedule without row
143
140
 
144
141
  ## Agent Plan lifecycle — close the loop
145
142
 
146
- When spawned by a `scheduled.task` for an Agent Plan row:
147
-
148
- 1. Execute the task (send DM, fire notification, run check-in).
149
- 2. Append to Agent Log: `- HH:MM [agent_plan] <action> — <outcome>`
150
- Outcomes: `DM sent`, `notify sent`, `skipped (user in meeting)`, `failed: <reason>`
151
- 3. Read today.md, locate the matching Agent Plan row (match HH:MM + action text), flip `[ ]` → `[x]`:
152
- ```bash
153
- curl -s http://localhost:8321/api/context/today
154
- # Edit the agent_plan section body, then:
155
- curl -s -X PATCH http://localhost:8321/api/context/today \
156
- -H 'Content-Type: application/json' \
157
- -d '{"section": "agent_plan", "mode": "replace", "content": "- [x] 08:55 ..."}'
158
- ```
159
- **Read-before-write is mandatory** — PATCH replace replaces the entire section.
160
- 4. If the Agent Plan row is missing (user hand-edited), log and skip.
161
- 5. Always flip to `[x]`, even for skips/failures — annotate non-success:
162
- - Success: no annotation
163
- - Skip: `⚠ skipped: <reason>`
164
- - Failure: `⚠ failed: <reason>`
165
- 6. If PATCH returns 409 (Morning Routine lock), retry after 30s up to 3 times. If still locked, log `loop-closeout deferred`.
166
-
167
- **Why flip inside the scheduled task, not later?** The user may DM at 09:00 asking "did you send the reminder?" — if the row is still `[ ]`, the DM handler can't tell whether it was sent.
143
+ `scheduled.task` and `scheduled.dm` (and any other event that flips an
144
+ Agent Plan row) follow the close-the-loop lifecycle in the reference
145
+ below: execute, append Agent Log entry, read-then-flip the row to
146
+ `[x]` with annotation, retry on `state/today.md` lock, surface missing-row
147
+ state.
148
+
149
+ DM handlers and hourly checks do not flip Agent Plan rows — read the
150
+ reference only if your event type is in its applicability list.
151
+
152
+ {{> ref:agent-plan-lifecycle }}
168
153
 
169
154
  ## Agent Log format
170
155
 
@@ -193,7 +178,7 @@ so the LLM never sees this format-using event with a wider lookahead.
193
178
  No additional gate is restated here.
194
179
 
195
180
  **Agent Notes**:
196
- `- 📅 event_title starts at HH:MM [— blocks/relates to: <task>]`
181
+ `- event_title starts at HH:MM [— blocks/relates to: <task>]`
197
182
 
198
183
  **Agent Log** (always):
199
184
  `- HH:MM [cal] event_title — action`
@@ -204,36 +189,21 @@ Morning Routine acquires exclusive lock. Other sessions get 409 on PUT/PATCH (GE
204
189
 
205
190
  PUT today.md must contain the H1 date line, day-type header quote, and all six sections in order.
206
191
 
207
- ## today.md API (subset of context API)
208
-
209
- Body submission follows the rule in `_safety.md` "Daemon-API body
210
- submission": small section PATCHes use inline `-d '{...}'`; full-file
211
- PUT uses the stdin heredoc `-d @- <<'JSON'` shape because the body
212
- runs multi-KB. Add `X-Lock-Id: <today_write_lock_id>` on every
213
- PUT / PATCH when that tag is in your context.
214
-
215
- ```bash
216
- # Read
217
- curl -s http://localhost:8321/api/context/today
218
-
219
- # Full replace Morning Routine only. Multi-KB body heredoc.
220
- curl -s -X PUT http://localhost:8321/api/context/today \
221
- -H 'Content-Type: application/json' \
222
- -H 'X-Lock-Id: <today_write_lock_id>' \
223
- -d @- <<'JSON'
224
- {"content":"# 2026-04-02 (Thursday)\n> Day type: Weekday | Work focus: on | Study focus: on | Personal focus: on\n\n## User Schedule\n- 14:00–15:00 Design review [work]\n\n## User Tasks\n- [ ] 11:00 Finalize Q2 draft [work]\n\n## Agent Plan\n- [ ] 08:55 DM reminder: standup [work] →DM\n\n## Agent Notes\n\n## Agent Log\n- 04:00 Morning Routine completed (day-type: Weekday)\n\n## Handoff\n- (none)\n"}
225
- JSON
226
-
227
- # Section operation — small body, inline `-d` is fine.
228
- curl -s -X PATCH http://localhost:8321/api/context/today \
229
- -H 'Content-Type: application/json' \
230
- -H 'X-Lock-Id: <today_write_lock_id>' \
231
- -d '{"section":"agent_log","mode":"append","content":"- 09:35 ..."}'
232
- ```
233
-
234
- The H1 date and the `> Day type:` quote line are validated by exact
235
- regex on PUT — keep both English-shaped exactly as the template. See
236
- context skill for the full endpoint reference.
192
+ ## today.md API
193
+
194
+ The generic GET / PUT / PATCH / DELETE surface — modes, fields, error
195
+ envelopes, body-submission shape is documented in the **context**
196
+ skill `references/api.md`. today.md-specific rules layered on top:
197
+
198
+ - **Lock.** `state/today.md` is locked by the Morning Routine. Include
199
+ `X-Lock-Id: <today_write_lock_id>` on every PUT / PATCH when the
200
+ tag is in your context; other sessions get `409
201
+ morning_routine_lock_held` while the lock is held.
202
+ - **Skeleton validators.** PUT is rejected (400) if line 1 fails the
203
+ H1 date regex or line 2 fails the day-type quote regex (see §"Line 1
204
+ which date?" and §"Header line day-type filter" above). PUT is
205
+ also rejected (400) if line 1's date disagrees with the daemon's current
206
+ agent-day the error echoes both values.
237
207
 
238
208
  ## Knowledge map — section shape (auto-curated)
239
209
 
@@ -5,9 +5,9 @@
5
5
  "id": "section-shape",
6
6
  "kind": "knowledge_layout",
7
7
  "anchor": "<!-- CURATION:knowledge_layout id=\"section-shape\" -->",
8
- "human_label": "today.md section shape",
8
+ "human_label": "state/today.md section shape",
9
9
  "description": "Required sections in today.md and what each holds",
10
- "scope_paths": ["today.md"]
10
+ "scope_paths": ["state/today.md"]
11
11
  },
12
12
  {
13
13
  "id": "agent-notes-flavors",
@@ -15,7 +15,7 @@
15
15
  "anchor": "<!-- CURATION:convention_notes id=\"agent-notes-flavors\" -->",
16
16
  "human_label": "Agent Notes flavors",
17
17
  "description": "Sub-shapes the agent uses inside ## Agent Notes (look-ahead, day-time observation, latent profile question)",
18
- "scope_paths": ["today.md"]
18
+ "scope_paths": ["state/today.md"]
19
19
  }
20
20
  ]
21
21
  }
@@ -0,0 +1,114 @@
1
+ ---
2
+ kind: reference
3
+ name: agent-plan-lifecycle
4
+ description: Agent Plan close-the-loop lifecycle for scheduled.task / scheduled.dm sessions — execute, log, flip [x], handle missing rows / failures / lock retries.
5
+ ---
6
+
7
+ # Agent Plan lifecycle — close the loop
8
+
9
+ This reference is consumed by `scheduled.task`, `scheduled.dm`,
10
+ `routine.morning_routine`, and `routine.evening_review` — every event
11
+ that may flip an Agent Plan row. DM handlers and hourly checks never
12
+ flip Agent Plan rows; if you are not one of the listed events, the
13
+ lifecycle below does not apply to your turn.
14
+
15
+ ## Why flip inside the scheduled task, not later?
16
+
17
+ The user may DM at 09:00 asking "did you send the reminder?" — if the
18
+ matching Agent Plan row is still `[ ]`, the DM handler cannot tell
19
+ whether the reminder was sent. The flip must land in the same turn as
20
+ the action it represents, before the session exits.
21
+
22
+ ## Steps (when spawned by `scheduled.task` for an Agent Plan row)
23
+
24
+ 1. **Execute the task.** Send the DM, fire the notification, run the
25
+ check-in — whatever the row's action text describes. The row's
26
+ trigger tag (`→DM`, `→notify`, `→check-in`, `→wake`) selects the
27
+ API surface (see `today` skill §"Entry formats").
28
+
29
+ 2. **Append an Agent Log entry** describing the outcome:
30
+
31
+ ```
32
+ - HH:MM [agent_plan] <action> — <outcome>
33
+ ```
34
+
35
+ Outcomes (use exactly one, lowercase):
36
+ - `DM sent`
37
+ - `notify sent`
38
+ - `check-in done`
39
+ - `wake fired`
40
+ - `skipped (<reason>)` — e.g. `skipped (user in meeting)`,
41
+ `skipped (focus off)`, `skipped (deduped)`
42
+ - `failed: <reason>` — short, single-line, no stack trace
43
+
44
+ Agent Log entries are mandatory before the flip, not after. If the
45
+ PATCH that flips the row to `[x]` fails, the log entry is the only
46
+ record that the action ran.
47
+
48
+ 3. **Read today.md, locate the matching Agent Plan row** (match HH:MM
49
+ + action text), and flip `[ ]` → `[x]`:
50
+
51
+ ```bash
52
+ curl -s http://localhost:8321/api/context/state/today
53
+ # Find the agent_plan section. Edit the matching row's checkbox.
54
+ # Then PATCH the full updated section body:
55
+ curl -s -X PATCH http://localhost:8321/api/context/state/today \
56
+ -H 'Content-Type: application/json' \
57
+ -H 'X-Lock-Id: <today_write_lock_id>' \
58
+ -d '{"section": "agent_plan", "mode": "replace", "content": "<full merged section>"}'
59
+ ```
60
+
61
+ **Read-before-write is mandatory** — `PATCH mode: "replace"` replaces
62
+ the entire section body. Send only the flipped row and you erase
63
+ every other Agent Plan row.
64
+
65
+ 4. **If the Agent Plan row is missing** (user hand-edited, row was
66
+ pruned by Evening Review, race with a concurrent rewrite), log
67
+ `skipped (row_missing)` to Agent Log and exit. Do not append a
68
+ new row to back-fill — the row's absence is informative state.
69
+
70
+ ## Flip-to-[x] cardinality rule
71
+
72
+ **Always flip to `[x]`, even for skips and failures.** The cardinality
73
+ rule is: every Agent Plan row reaches exactly one terminal state per
74
+ agent-day, and that state is `[x]`. Annotate the non-success cases in
75
+ parentheses appended to the action text:
76
+
77
+ | Outcome | Row content after flip |
78
+ |---|---|
79
+ | Success | `- [x] HH:MM <action> [category] →<trigger>` (no annotation) |
80
+ | Skip | `- [x] HH:MM <action> [category] →<trigger> (skipped: <reason>)` |
81
+ | Failure | `- [x] HH:MM <action> [category] →<trigger> (failed: <reason>)` |
82
+
83
+ Leaving rows as `[ ]` is a bug: Morning Routine's reconciliation
84
+ treats unflipped past rows as "scheduler dropped the wake", which
85
+ triggers self-recovery and inflates the agent-actions audit.
86
+
87
+ ## Lock retry rules
88
+
89
+ The Morning Routine holds the `state/today.md` write lock. Other sessions
90
+ get `409 morning_routine_lock_held` on PUT / PATCH while the lock is held.
91
+
92
+ - Detect by the response body `{"error":"morning_routine_lock_held"}`
93
+ (with `errors[0].code: "context.morning_routine_lock_held"`) or by the
94
+ status code 409 alone.
95
+ - Retry policy: 30 s back-off, max 3 attempts. If the third attempt
96
+ also returns 409, log `loop-closeout deferred (lock_held)` to Agent
97
+ Log and exit. The next Evening Review reconciliation will catch the
98
+ un-flipped row.
99
+ - Do NOT retry without the `X-Lock-Id` header when the tag is in
100
+ context. Sending a PATCH without the header during a held-lock
101
+ window returns 409 even though you would have been allowed in
102
+ during a no-lock window.
103
+
104
+ ## What this lifecycle does NOT cover
105
+
106
+ - Agent Notes flavors and their flips (`Profile question (latent)` ↔
107
+ `Profile question (asked HH:MM)`) — those live in the
108
+ `user-interview` skill, not in this lifecycle.
109
+ - The schedule.approaching → Agent Notes / Agent Log format — that
110
+ is in the `today` skill body (§"schedule.approaching → Agent Notes
111
+ + Agent Log"), not here. The 15-minute firing gate is the daemon's,
112
+ not the skill's.
113
+ - The Morning Routine's initial population of Agent Plan rows — see
114
+ the morning routine task-flow.