@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,330 @@
1
+ ---
2
+ name: management-task-register
3
+ description: Register a new recurring agent fetch against a third-party app from a DM — "check Zoom recordings daily at 10am", "check Gmail daily for invoices". Owns INSERT on §B "Managed tasks" rows. SKIP for one-off reminders, modify, stop.
4
+ when_to_use: User asks to start a recurring external-app fetch / check / sync (Zoom, Gmail, Drive, Notion, custom MCP). SKIP for one-off reminders (`schedule`), durable rules without an external app (`management-policy`), or pure DM cadence (`schedule` recurring).
5
+ allowed-tools:
6
+ - Bash(curl *)
7
+ - Bash(jq *)
8
+ - Read
9
+ ---
10
+
11
+ # Register a Managed Task
12
+
13
+ A **managed task** (`mt_<n>`) is a user-delegated commitment: the agent
14
+ runs a recurring fetch against a specific App at a user-specified
15
+ Cadence and writes the resulting entities into a primary L2 directory
16
+ (the `Output path`). Each row lives in `rules/management.md` §B. The
17
+ authoritative store is the `managed_tasks` SQLite table; the file is
18
+ re-rendered from the table after every mutation, so do **not** PUT the
19
+ file yourself — every legal mutation goes through
20
+ `/api/managed-tasks` and the daemon owns the file write.
21
+
22
+ ## When to use
23
+
24
+ The user's DM clearly asks for a **recurring fetch / check / sync
25
+ against a third-party app** with a cadence:
26
+
27
+ - "Check Zoom recordings every day at 10am"
28
+ - "Check Gmail daily and triage invoices into receipts"
29
+ - "Every Monday at 9 pull new Drive PDFs into receipts"
30
+ - "Check Notion 'Reading' DB every evening and surface unread"
31
+
32
+ ## When NOT to use
33
+
34
+ | Shape | Use instead |
35
+ |---|---|
36
+ | One-off "remind me at 3pm to call the bank" | `schedule` (`/api/schedule/dm`) |
37
+ | Recurring DM with no external-app fetch ("ping me every Monday at 9") | `schedule` recurring-schedules |
38
+ | "From now on, when X happens, do Y" passive rule with no cadence | `management-policy` |
39
+ | Tone / style / single fact about the user | `user-profile` |
40
+ | Source-of-Truth declaration ("notes live in Obsidian") | A-section binding via `PUT /api/sot-bindings` (separate flow) |
41
+ | Modify cadence / output of an existing `mt_<n>` | `management-task-modify` |
42
+ | Stop an existing `mt_<n>` | `management-task-stop` |
43
+ | Run an existing `mt_<n>` once, off-schedule | `POST /api/managed-tasks/<id>/run-now` |
44
+
45
+ If the user already has `mt_<n>` for the same app+cadence, this skill
46
+ **refuses** with a DM pointing at the existing row — that is the dedup
47
+ contract (FR-2). Do not register a duplicate.
48
+
49
+ ## Algorithm (mirror of design 21 §10.1)
50
+
51
+ Run the steps in order. Any step's failure DMs the user with the
52
+ verbatim reason and ends the flow — never skip, never silently retry,
53
+ never hardcode a tool name (FR-4 / ADR §8.4).
54
+
55
+ ### Step 1 — Read current state
56
+
57
+ ```bash
58
+ curl -s "http://localhost:8321/api/context/rules/management" | jq -r .content
59
+ ```
60
+
61
+ Extract §B (Managed tasks) and §A (Source-of-Truth bindings). §A tells
62
+ you which app already owns a category (e.g. `tasks → notion`); a
63
+ duplicate-cadence registration against an unrelated app for the same
64
+ category is a smell and should be confirmed before registering.
65
+
66
+ ### Step 2 — Semantic dedup (LLM judgment)
67
+
68
+ For each existing §B row, compare the requested
69
+ `(app_normalized, cadence_semantic, intent_semantic)` against the row.
70
+ Treat a row as a **high-confidence match** when:
71
+
72
+ - `app_normalized` matches case-insensitively (e.g. `zoom` ≡ `Zoom`),
73
+ AND
74
+ - the cadence resolves to the same structured recurrence, AND
75
+ - the intent describes the same fetch shape (e.g. "recordings → meeting
76
+ entity" is the same as "new recordings → meeting entity").
77
+
78
+ On a match, DM the user verbatim with the existing row's id, cadence
79
+ and last result, and stop:
80
+
81
+ > Already managed as `mt_42` (daily 10:00 — last run ok 3 new). Modify
82
+ > or stop it via DM.
83
+
84
+ If multiple plausible matches exist, ask the user which one to update
85
+ and end the flow (the user's reply triggers `management-task-modify`).
86
+
87
+ If §B already holds the cap (default 100, configurable
88
+ `managementMaxActiveTasks`), refuse with a DM pointing at the cap; the
89
+ user must stop something first.
90
+
91
+ ### Step 3 — Tool selection (LLM judgment, in-session)
92
+
93
+ Enumerate the tools available to this session (`mcp__*`, native
94
+ backend connectors, custom MCP servers the user installed). Ask
95
+ yourself: *"Which of these, if any, lets me read the user-typed app
96
+ label?"*
97
+
98
+ - **Zero plausible** → DM "I don't see a connected tool for `<app>` on
99
+ this backend. Connect one and ask again." Stop.
100
+ - **Multiple plausible** → DM the user with the candidates verbatim
101
+ and ask which one to use. Stop. (The user's reply re-enters this
102
+ flow with the chosen tool as a hint.)
103
+ - **One plausible** → continue.
104
+
105
+ NEVER hardcode tool names or pattern-match against
106
+ `mcp__claude_ai_<App>__*`. The user may have installed a custom MCP
107
+ with non-standard names — you read the tool description and pick by
108
+ **capability**, not by name.
109
+
110
+ ### Step 4 — Read-only probe
111
+
112
+ Invoke the chosen tool with the **smallest** read-only payload that
113
+ proves connectivity and authorization (e.g. list the first page with
114
+ `limit: 1`, fetch the user's profile / "me" endpoint, search for an
115
+ empty string). Do NOT mutate state.
116
+
117
+ On any error — auth failure, network error, schema error,
118
+ out-of-quota — DM the verbatim error message with one line of context
119
+ and stop:
120
+
121
+ > Couldn't reach `<app>`: `<verbatim error from tool>`.
122
+
123
+ The probe failure must surface the connector's own error string, not a
124
+ paraphrase. The user is the one who can fix auth / quota / install.
125
+
126
+ ### Step 4a — Decide `Output path` (LLM judgment)
127
+
128
+ From the probe sample, infer the primary L2 directory the recurring
129
+ fetch will write into. Bias toward existing matches:
130
+
131
+ 1. If the entity-mirror already holds entities with `sources.<app>.*`
132
+ under one `<domain>/<type-plural>/`, reuse that path. Probe with:
133
+ ```bash
134
+ curl -s "http://localhost:8321/api/entities?source=<app>&limit=5" | jq .
135
+ ```
136
+ The response is `{tier:1, mode:"by_source_key", items:[…]}`; each
137
+ item's `path` (`<domain>/<type-plural>/<slug>.md`) reveals where
138
+ that source already lives. If 1+ rows agree on `<domain>/<type>`,
139
+ that path wins.
140
+ 2. Otherwise, pick the `(domain, type)` pair whose semantic prior best
141
+ fits the data shape. Reference table:
142
+
143
+ | Probe sample shape | Likely `<domain>/<type-plural>/` |
144
+ |---|---|
145
+ | Recording with attendees + duration | `work/meetings/` |
146
+ | PDF / image with monetary amount | `finance/receipts/` |
147
+ | Task / ticket / issue | one of the project domains' `projects/` (rare — typically the Tasks SoT mirror handles this; only register a managed task if the SoT is *another* app) |
148
+ | Travel itinerary / booking | `travel/trips/` |
149
+ | Long-form note / article | `<domain>/notes/` (pick by content topic) |
150
+ | Book metadata / progress | `learning/books/` |
151
+ 3. If the data shape is genuinely ambiguous (e.g. the probe returned
152
+ zero rows), set `output_path: null` — the first scheduled run will
153
+ populate it from real data.
154
+
155
+ **Path validation invariant** (§9.3, §13.3):
156
+
157
+ - Format: `<domain>/<type-plural>/` — leading `context/` is implicit
158
+ and must NOT be included; the trailing `/` is mandatory.
159
+ - `<domain>` ∈ `{work, travel, finance, personal, health, learning}`.
160
+ - `<type-plural>` ∈ `{meetings, trips, receipts, projects, books, notes}`.
161
+ - No `..` segments. No absolute paths.
162
+
163
+ The daemon CHECKs the constraint at INSERT/UPDATE time and rejects with
164
+ a 422 — surface that error verbatim if it fires. Pre-validate to avoid
165
+ the round-trip when you can.
166
+
167
+ ### Step 5 — Resolve cadence to a `recurrenceRule`
168
+
169
+ Translate the user's natural-language cadence into:
170
+ - a free-text `cadence` string (what gets rendered in §B), AND
171
+ - a structured `recurrenceRule` (what the scheduler executes).
172
+
173
+ The daemon's recurrence engine accepts only `daily` / `weekly` /
174
+ `monthly`. Sub-daily ("every hour", "every 5 minutes") is **not
175
+ representable** — refuse those with a DM and ask for a daily-or-coarser
176
+ cadence. Times are `HH:MM` 24-hour local; timezone is IANA (auto-fills
177
+ from daemon config when omitted, but it's safer to pass it explicitly
178
+ so a roaming laptop doesn't surprise the user).
179
+
180
+ | User said | `cadence` | `recurrenceRule` |
181
+ |---|---|---|
182
+ | every day at 10am (Asia/Tokyo) | `daily 10:00 (Asia/Tokyo)` | `{frequency:"daily", time:"10:00", timezone:"Asia/Tokyo"}` |
183
+ | every Monday 9am | `weekly Mon 09:00` | `{frequency:"weekly", time:"09:00", timezone:<user tz>, daysOfWeek:[1]}` |
184
+ | every weekday at 8am | `weekdays 08:00` | `{frequency:"weekly", time:"08:00", timezone:<user tz>, daysOfWeek:[1,2,3,4,5]}` |
185
+ | 1st of every month at noon | `monthly day 1 12:00` | `{frequency:"monthly", time:"12:00", timezone:<user tz>, daysOfMonth:[1]}` |
186
+ | every hour | _refuse_ | _refuse_ |
187
+ | every 5 minutes | _refuse_ | _refuse_ |
188
+
189
+ `daysOfWeek` is `0=Sun..6=Sat`; `daysOfMonth` is `1..31` (29-31 clamp
190
+ to last day of short months). `daysOfWeek` is forbidden on `daily` and
191
+ `monthly`; `daysOfMonth` is forbidden on `daily` and `weekly` — the
192
+ daemon's Zod refinements reject mismatches with a `validation_error`.
193
+
194
+ For sub-daily requests, refuse with a DM:
195
+
196
+ > The agent's recurrence engine only supports daily, weekly, or monthly
197
+ > cadences. `every hour` is too tight — pick `daily` or coarser.
198
+
199
+ ### Step 6 — POST /api/managed-tasks
200
+
201
+ ```bash
202
+ curl -sS -X POST http://localhost:8321/api/managed-tasks \
203
+ -H 'Content-Type: application/json' \
204
+ -H 'Idempotency-Key: <opaque uuid for this DM>' \
205
+ -d @- <<'JSON'
206
+ {
207
+ "intent": "Zoom recordings → meeting entity",
208
+ "app": "zoom",
209
+ "cadence": "daily 10:00 (Asia/Tokyo)",
210
+ "recurrenceRule": {
211
+ "frequency": "daily",
212
+ "time": "10:00",
213
+ "timezone": "Asia/Tokyo"
214
+ },
215
+ "output_path": "work/meetings/"
216
+ }
217
+ JSON
218
+ ```
219
+
220
+ | Field | Required | Notes |
221
+ |---|---|---|
222
+ | `intent` | yes | ≤ 200 chars, NFC, no newlines, no pipe chars |
223
+ | `app` | yes | ≤ 64 chars, NFC, no newlines, no pipe chars; user-typed label preserved verbatim (case + non-ASCII OK) |
224
+ | `cadence` | yes | Human-readable; rendered in §B (≤ 200 chars) |
225
+ | `recurrenceRule` | yes | `{frequency:"daily"\|"weekly"\|"monthly", time:"HH:MM", timezone?:<IANA>, daysOfWeek?:[0..6], daysOfMonth?:[1..31]}` — see Step 5 table |
226
+ | `output_path` | no | `<domain>/<type-plural>/` per §9.3, ending `/`; omit while undecided (the first scheduled run back-fills it) |
227
+
228
+ The response is `{status:"created", item:<ManagedTask>, render_status:"ok"|"lock_contended:..."}`.
229
+ On an idempotent replay (same `Idempotency-Key` within 24 h, the row
230
+ still exists) you get `{status:"idempotent_replay", item:<ManagedTask>}`
231
+ with HTTP 200 — treat that as success, not a duplicate registration.
232
+
233
+ **Idempotency-Key.** Generate a stable key per DM (e.g. SHA-256 of the
234
+ inbound message id + app). Concurrent retries collapse to the same
235
+ `mt_<n>`; a different key with the same `app+cadence` collides at the
236
+ `(app_normalized, cadence)` uniqueness check and the second POST returns
237
+ `409 conflict` with the existing `mt_id` — DM the user pointing at it
238
+ instead of registering twice.
239
+
240
+ **Server-side transaction (atomic).** The daemon allocates the next
241
+ `mt_<n>` from `managed_task_seq`, INSERTs `recurring_schedules` and
242
+ `managed_tasks` linked by FK, and writes one `agent_actions` row
243
+ (`action_type='management_task.created'`). On any DB failure the
244
+ transaction rolls back and you get a 5xx — surface the body verbatim.
245
+
246
+ **File render.** Post-transaction the daemon re-renders
247
+ `rules/management.md` from DB (locked, snapshotted into
248
+ `md_file_snapshots`). You do NOT touch the file.
249
+
250
+ ### Step 7 — Confirm to user
251
+
252
+ DM the user once with the assigned id (`item.id` from the POST
253
+ response), the resolved output path (`item.output_path`), and the
254
+ human cadence label (`item.cadence`). The next firing time is owned by
255
+ the scheduler — phrase the confirmation around the cadence rather than
256
+ fabricating a clock time.
257
+
258
+ > Registered as `mt_43` (Zoom · daily 10:00 JST). Output → `work/meetings/`. Starts at the next 10:00 JST slot.
259
+
260
+ Persona / language rules are in `notify` — the message itself follows
261
+ the awareness gate and no-ceremony rules. Don't enumerate the steps
262
+ ("did probe, did INSERT, did re-render"); the daemon already audited
263
+ them.
264
+
265
+ ## Validation cheatsheet (§13.3)
266
+
267
+ | Field | Rule | Reject example |
268
+ |---|---|---|
269
+ | `app` | trimmed; NFC; ≤ 64 chars; no `\n`; no `\|` | `\|gmail` |
270
+ | `intent` | trimmed; NFC; ≤ 200 chars; no `\n`; no `\|` | `<5×40 chars>` |
271
+ | `cadence` | free text, ≤ 200 chars | _any non-empty string_ |
272
+ | `recurrenceRule.frequency` | `daily` \| `weekly` \| `monthly` | `hourly`, `every-5-min` |
273
+ | `recurrenceRule.time` | `HH:MM` zero-padded | `9:00`, `25:00` |
274
+ | `recurrenceRule.timezone` | IANA zone string (auto-fills from daemon when omitted) | `EST+9` |
275
+ | `recurrenceRule.daysOfWeek` | required for `weekly`; forbidden otherwise; ints `0..6` | `[7]`, `[]` |
276
+ | `recurrenceRule.daysOfMonth` | required for `monthly`; forbidden otherwise; ints `1..31` | `[0]`, `[32]` |
277
+ | `output_path` | `<domain>/<type-plural>/`; no `..`; trailing `/` | `work/meetings`, `../foo/`, `random/dir/` |
278
+ | `mt_id` | server-allocated; never craft client-side | n/a |
279
+
280
+ The daemon also enforces these — but pre-validating saves the user one
281
+ round-trip of error chatter.
282
+
283
+ ## Error envelope
284
+
285
+ | HTTP | `error` | What to do |
286
+ |---|---|---|
287
+ | 400 | `validation_error` | Body has Zod `details`; pick the offending field's message and ask the user to clarify. The Zod issue path tells you whether `recurrenceRule.*`, `app`, `output_path`, etc. is the culprit. |
288
+ | 409 | `duplicate` | Body includes `item` (the existing row); DM "Already managed as `<item.id>`" and stop |
289
+ | 409 | `cap_reached` | Surface `body.message` (cap value); user must stop something first |
290
+ | 5xx | `internal_error` | DM "Couldn't register; daemon error. Try again, or check `aitne logs`." |
291
+
292
+ `body.message` (when present) is intended for the user — preserve it
293
+ verbatim. The daemon does not currently emit `cron_too_tight` because
294
+ the recurrence schema only accepts daily/weekly/monthly — a sub-daily
295
+ ask never reaches POST; refuse it client-side per Step 5.
296
+
297
+ ## What this skill does NOT do
298
+
299
+ - Does NOT hardcode connector tool names — all tool selection is
300
+ LLM-judged (FR-4).
301
+ - Does NOT PUT `rules/management.md` directly — the daemon owns that
302
+ write (FR-12). The only legal write is `POST /api/managed-tasks`.
303
+ - Does NOT INSERT `recurring_schedules` directly. POST
304
+ `/api/managed-tasks` is the chokepoint that keeps the FK pair
305
+ consistent.
306
+ - Does NOT touch §A (SoT bindings). Use `PUT /api/sot-bindings` for
307
+ that (separate "sot" flow).
308
+ - Does NOT touch §C (Active Policies stub). Owned by
309
+ `management-policy`.
310
+ - Does NOT silently re-register on retry. Use `Idempotency-Key`
311
+ per-DM; conflicts surface the existing `mt_id`.
312
+ - Does NOT register a task that has no probe-passing connector. Probe
313
+ failure is a hard stop — never "register optimistically and hope".
314
+ - Does NOT proceed when the vault is in degraded mode
315
+ (`Dispatcher.isAutonomousAllowed()` already filters). Trust that
316
+ upstream.
317
+
318
+ ## API summary
319
+
320
+ | Verb + path | Used in |
321
+ |---|---|
322
+ | `GET /api/context/rules/management` | Step 1 (read §A + §B) |
323
+ | `GET /api/entities?source=<app>` | Step 4a (output-path bias) |
324
+ | `GET /api/managed-tasks` | Optional — alternative to parsing the file |
325
+ | `POST /api/managed-tasks` | Step 6 (Notify-tier; the daemon DMs confirmation; no Approve gate) |
326
+ | `POST /api/notify` | Step 7 (your own DM-to-user reply) — uses the `notify` skill's discipline |
327
+
328
+ Every state-changing call is recorded in `agent_actions` and the file
329
+ is snapshotted into `md_file_snapshots` — do NOT post a separate audit
330
+ event yourself.
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: management-task-stop
3
+ description: Stop (hard-delete) an existing managed task (`mt_<n>`) from a DM — "stop the daily Zoom check", "cancel mt_42". Owns DELETE on §B rows. SKIP for cadence tweaks (modify), pause (no soft-pause), or one-off skip.
4
+ when_to_use: User wants to end a recurring agent commitment. SKIP for cadence / intent / output-path tweaks (`management-task-modify`), pause-then-resume (no soft-pause exists; user must re-register), or removing a one-off scheduled task (`schedule` skill DELETE).
5
+ allowed-tools:
6
+ - Bash(curl *)
7
+ - Bash(jq *)
8
+ - Read
9
+ ---
10
+
11
+ # Stop a Managed Task
12
+
13
+ Hard-deletes a managed-task row. The `recurring_schedules` row
14
+ cascade-deletes via FK and any pending `agent_schedule` rows for the
15
+ old cron are cancelled. History is preserved entirely in
16
+ `agent_actions` (`action_type='management_task.deleted'`) and
17
+ `md_file_snapshots` — there is no soft-stop placeholder in the
18
+ file (ADR §8.5).
19
+
20
+ ## When to use
21
+
22
+ The user clearly asks to **end** a recurring commitment:
23
+
24
+ - "Stop the daily Zoom check"
25
+ - "Cancel `mt_42`"
26
+ - "Remove the gmail invoice triage — I'm not reading those anymore"
27
+ - "I don't need the Drive receipts pull anymore"
28
+
29
+ ## When NOT to use
30
+
31
+ | Shape | Use instead |
32
+ |---|---|
33
+ | User wants to keep it running but tweak it | `management-task-modify` |
34
+ | User wants to pause for a few days then resume | No soft-pause exists. Stop now; user re-registers when they want it back. Spell this out in the confirmation. |
35
+ | User wants to skip exactly one upcoming run | DELETE the pending `/api/schedule/:id` row (the row in `agent_schedule`); the next slot fires normally. Use the `schedule` skill. |
36
+ | User wants to drop a one-off `/api/schedule` reminder | `schedule` skill DELETE |
37
+ | User wants to clear `_activity/<source>.md` | The reconciler regenerates it within 90 days; nothing to delete here |
38
+
39
+ ## Algorithm (mirror of design 21 §10.3)
40
+
41
+ ### Step 1 — Locate the row
42
+
43
+ Same lookup as `management-task-modify`. Either the user named the id
44
+ directly, or you fuzzy-match by `(app, cadence, intent)`.
45
+
46
+ ```bash
47
+ curl -s "http://localhost:8321/api/managed-tasks/mt_42" | jq .item
48
+ # or:
49
+ curl -s "http://localhost:8321/api/managed-tasks" | jq '.items[] | select(.app_normalized == "zoom")'
50
+ ```
51
+
52
+ GET-by-id wraps the row in `{item:<row>}`; the list returns
53
+ `{items:[…], count:N}`.
54
+
55
+ If multiple rows could match, list them and ask which to stop. Stop
56
+ until the user picks. **Never stop more than one row in a single
57
+ turn.** A bulk stop ("stop all gmail tasks") requires explicit
58
+ confirmation per row.
59
+
60
+ If no row matches, DM:
61
+
62
+ > No managed task for `<app>` is registered.
63
+
64
+ ### Step 2 — Confirm with the user (Notify tier — destructive)
65
+
66
+ DELETE on a managed task is **Notify tier** (§13.1) AND removes a
67
+ recurring commitment that the user themselves set up. Both safety
68
+ invariants ("destructive ops require user confirmation" from
69
+ CLAUDE.md, plus the Notify-tier policy) demand a real DM confirmation
70
+ in the user's preferred language. Never auto-stop.
71
+
72
+ > Stop `mt_42` Zoom check (daily 10:00 JST · last run ok 3 new)? It
73
+ > won't auto-resume.
74
+
75
+ If the user declines, stop the flow. If they amend ("actually just
76
+ make it weekly"), route to `management-task-modify` instead — do not
77
+ stop and re-register on their behalf.
78
+
79
+ The "last run" line in the confirmation matters: a row that has been
80
+ silently failing (`consecutive_failures ≥ 3`) is exactly the kind the
81
+ user is most likely stopping by mistake (they may not realize the
82
+ failures alone are the problem). Surface `last_result` so they can
83
+ make an informed call.
84
+
85
+ ### Step 3 — DELETE /api/managed-tasks/:id
86
+
87
+ ```bash
88
+ curl -sS -X DELETE http://localhost:8321/api/managed-tasks/mt_42
89
+ ```
90
+
91
+ The server-side transaction (atomic):
92
+
93
+ a. snapshots the row's full state into `agent_actions.detail`,
94
+ b. DELETEs `managed_tasks` (cascades to `recurring_schedules` via FK),
95
+ c. cancels pending `agent_schedule` rows for the old cron,
96
+ d. re-renders `rules/management.md` from DB (locked + snapshotted into
97
+ `md_file_snapshots`),
98
+ e. INSERTs `agent_actions` (`action_type='management_task.deleted'`,
99
+ `detail={mt_id, original_row, deleted_at, by_user_message}`).
100
+
101
+ The pre-delete file snapshot in `md_file_snapshots` plus the
102
+ `detail.original_row` blob in `agent_actions` together let the user
103
+ or the activity-view reconciler reconstruct the row at any later
104
+ date — there is no further "soft-stop" archive needed.
105
+
106
+ ### Step 4 — Confirm to user
107
+
108
+ One DM:
109
+
110
+ > Stopped `mt_42` Zoom check. The row is gone from the registry; ask
111
+ > me to register a new one any time.
112
+
113
+ Persona / language rules from `notify` apply. Don't list the internal
114
+ mechanics ("snapshotted, cascade-deleted") — the audit log is for
115
+ the agent, not the user.
116
+
117
+ The `_activity/zoom.md` file's "Recently changed (90d)" section
118
+ auto-updates within ~10 s as the activity-view reconciler picks up
119
+ the new `agent_actions` row. You do NOT touch that file.
120
+
121
+ ## Error envelope
122
+
123
+ | HTTP | `error` | What to do |
124
+ |---|---|---|
125
+ | 400 | `invalid_id` | The `:id` segment didn't match `^mt_[1-9]\d*$`; ask the user to repeat |
126
+ | 404 | `not_found` | DM "No managed task with that id"; if you used a fuzzy match, re-list candidates |
127
+ | 5xx | `internal_error` | Surface `body.message` if present; advise `aitne logs` |
128
+
129
+ The daemon's DELETE is unconditional — there is no `running_now` /
130
+ `?force=true` in-flight guard today. If the cascade collides with a
131
+ fire that is mid-execution the dispatcher's retry / orphan-detection
132
+ path picks it up; do not try to "wait for it to finish" in the skill.
133
+
134
+ The pre-delete row snapshot in `agent_actions` (`detail.original_row`)
135
+ together with the file snapshot in `md_file_snapshots` is the
136
+ recovery surface — surface it in audit/debug contexts only, never in
137
+ the user-facing DM.
138
+
139
+ ## What this skill does NOT do
140
+
141
+ - Does NOT pause / disable. There is no soft-stop; the row is gone.
142
+ If the user wants a temporary hiatus, tell them they'll need to
143
+ re-register when ready.
144
+ - Does NOT delete entity files (`<domain>/<type-plural>/<slug>.md`)
145
+ produced by past runs. Those stay; the user's notes / receipts are
146
+ not the agent's to discard.
147
+ - Does NOT regenerate `_activity/<source>.md`. The reconciler does.
148
+ - Does NOT manipulate `recurring_schedules` directly. DELETE
149
+ `/api/managed-tasks/:id` is the chokepoint; cascade is automatic.
150
+ - Does NOT touch §A (SoT bindings) or §C (Active Policies).
151
+ - Does NOT PUT `rules/management.md` directly. The daemon owns the
152
+ file write.
153
+ - Does NOT bulk-stop without per-row confirmation. "Stop all gmail
154
+ tasks" is a series of DM round-trips, one per row.
155
+
156
+ ## API summary
157
+
158
+ | Verb + path | Used in |
159
+ |---|---|
160
+ | `GET /api/managed-tasks` / `/api/managed-tasks/:id` | Step 1 (lookup) |
161
+ | `DELETE /api/managed-tasks/:id` | Step 3 (Notify-tier; destructive) |
162
+ | `POST /api/notify` | Step 4 (user-facing confirmation) |
163
+
164
+ The DELETE writes one `agent_actions` row, snapshots the file, and
165
+ cascades the schedule — do NOT call any separate audit / cleanup
166
+ endpoint.