@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,307 @@
1
+ ---
2
+ name: management-policy
3
+ description: Capture a durable management rule from a DM — "every morning X", "from now on when Y", or pause/resume/remove an existing one.
4
+ when_to_use: Wires policy file + linked routine + dossier together. SKIP for one-off `schedule`, tone preferences, or single user facts (`user-profile`).
5
+ allowed-tools:
6
+ - Bash(curl *)
7
+ - Read
8
+ ---
9
+
10
+ # Management Policy Capture
11
+
12
+ A **management policy** is a durable, ongoing rule the user wants the
13
+ agent to keep applying. It is NOT a one-off task.
14
+
15
+ Each policy lives at `rules/policies/<slug>.md` and may link to:
16
+
17
+ - `routines/custom/<slug>.md` — the cron-driven execution rulebook
18
+ - `dossiers/<topic>.md` — where the policy's accumulating data lands
19
+
20
+ A readable summary of every policy lives at `rules/policies/_index.md`,
21
+ which the daemon's policy-index reconciler **auto-maintains** from the
22
+ policy files on disk. The directory listing under `rules/policies/` is
23
+ the source of truth; `_index.md` is a derived snapshot — **do not
24
+ PATCH or PUT it by hand**. The same reconciler also re-renders the
25
+ `## Active Policies` section in `rules/management.md` so it stays in
26
+ sync. Both files refresh within ~10 s of any policy file write.
27
+
28
+ ## When to use this skill
29
+
30
+ Use when the user expresses a **durable, ongoing management rule**:
31
+
32
+ - "every morning, run my finance app and log the balance"
33
+ - "from now on, when a Linear ticket lands in the Inbox project, summarize it for me"
34
+ - "for travel, always check the weather the day before and DM me"
35
+ - "stop doing the daily X check" → policy pause/remove
36
+ - "actually let's resume the morning finance thing" → policy resume
37
+
38
+ ## When NOT to use this skill
39
+
40
+ | Shape | Use instead |
41
+ |---|---|
42
+ | One-off "remind me at 3pm to call the bank" | `schedule` |
43
+ | "Reply more tersely from now on" / tone, voice, style | `user-profile` (routes to `character`) |
44
+ | "I'm an NYC-based dev" / single user fact | `user-profile` |
45
+ | "Add a project for the Q3 roadmap" | `context` (`projects/*.md`) |
46
+ | Pure data write — "log this transaction" | direct context write to the relevant `dossiers/<topic>.md` |
47
+
48
+ If the user's request is **a recurring task with no need for a recorded
49
+ reason** (e.g. "ping me every Monday at 9 to start standup prep"), use
50
+ `schedule`'s recurring-schedules path. A management policy is the right
51
+ home only when the user wants the **why** captured alongside the
52
+ cadence so it survives a context reset.
53
+
54
+ ## Workflow
55
+
56
+ ### Step 1 — List existing policies (mandatory)
57
+
58
+ Read the auto-maintained index for a quick summary, then fall back to
59
+ the directory listing if you need authoritative state.
60
+
61
+ ```bash
62
+ # Auto-maintained by the daemon — fastest read for slug / status /
63
+ # cadence / linked routine + dossier / one-line why.
64
+ curl -s "http://localhost:8321/api/context/rules/policies/_index"
65
+
66
+ # Directory listing — authoritative source of truth. Use this if a
67
+ # specific policy file looks newer than the index (the reconciler
68
+ # debounces ~10 s; fresh writes may not be reflected yet).
69
+ curl -s "http://localhost:8321/api/context/list/rules"
70
+ ```
71
+
72
+ If the listing and `_index.md` rows disagree, **prefer the listing**
73
+ and trust the next reconcile pass to refresh the index. Do **not**
74
+ hand-PATCH `_index.md` to fix the drift — that just creates more churn.
75
+
76
+ ### Step 2 — Detect similarity
77
+
78
+ Heuristics to compare against existing policies:
79
+
80
+ | Signal | Likely interpretation |
81
+ |---|---|
82
+ | Same `linked.dossier` topic | Likely a duplicate or extension of an existing policy |
83
+ | Same cron expression on the linked routine | Likely a duplicate cadence |
84
+ | Slug stem matches an existing slug ("finance", "inbox", …) | Likely related |
85
+
86
+ If a candidate matches, ask the user **before** creating:
87
+
88
+ > "I already have `<existing-slug>` doing `<one-line why>` on
89
+ > `<cadence>`. Update that one, or create a new policy?"
90
+
91
+ Stop until the user picks. Do not create a duplicate silently.
92
+
93
+ ### Step 3 — Echo interpretation
94
+
95
+ Paraphrase the rule back in **one short paragraph**:
96
+
97
+ - the cadence (or trigger condition)
98
+ - the action
99
+ - where the data accumulates (which dossier)
100
+ - which existing routine / dossier you'll create or extend
101
+
102
+ Wait for an explicit yes. If the user corrects a detail, re-echo and
103
+ wait again.
104
+
105
+ ### Step 4 — Build the policy file
106
+
107
+ Emit the full `rules/policies/<slug>.md` content as a fenced markdown
108
+ block in the DM **before** writing, so the user sees what's about to be
109
+ saved. The slug must:
110
+
111
+ - equal the filename stem
112
+ - match `^[a-z0-9][a-z0-9-]*[a-z0-9]$` (or a single `[a-z0-9]`)
113
+ - be ≤ 64 chars
114
+ - equal the linked `routines/custom/<slug>.md` slug (if any) — keep
115
+ them aligned in v1
116
+
117
+ ### Step 5 — Wire the dependencies (strict order; on failure, roll back in reverse)
118
+
119
+ Each step gates the next. If step `N` fails, attempt to roll back steps
120
+ `N-1 … 1` in reverse before reporting the failure to the user.
121
+
122
+ #### 5.1 Create the dossier (if it doesn't exist)
123
+
124
+ ```bash
125
+ # Optional — only if the policy accumulates data into a new topic.
126
+ curl -sS -X PUT http://localhost:8321/api/context/dossiers/<topic> \
127
+ -H 'Content-Type: application/json' \
128
+ -d @- <<'JSON'
129
+ {"content":"---\ntype: dossier\nowner: agent\nupdated: 2026-04-24\n---\n# <Topic>\n\n## Daily Log\n"}
130
+ JSON
131
+ ```
132
+
133
+ Skip this step if `linked.dossier` is not set or the dossier already
134
+ exists. The dossier file is data only — no harm if it ends up empty
135
+ when the rest of the flow rolls back.
136
+
137
+ #### 5.2 Create the custom routine (if scheduling is needed)
138
+
139
+ ```bash
140
+ curl -sS -X PUT http://localhost:8321/api/context/routines/custom/<slug> \
141
+ -H 'Content-Type: application/json' \
142
+ -d @- <<'JSON'
143
+ {"content":"---\ntype: rule\nslug: <slug>\nprocess_key: routine.custom.<slug>\ncron: \"0 7 * * *\"\nbackend_tier: light\nmax_budget_usd: 0.20\nenabled: true\n---\n# <Title>\n\n## Checks\n\n### <step label>\n**Action**: …\n"}
144
+ JSON
145
+ ```
146
+
147
+ The route's `onCustomRoutinesChanged` hook reloads the cron scheduler
148
+ automatically — no separate reload call.
149
+
150
+ Skip this step if the policy is purely passive (e.g. "from now on, when
151
+ the user mentions X in DM, also …"). In that case the policy file
152
+ itself documents the rule and the relevant DM/event task-flow picks it
153
+ up via the global injection.
154
+
155
+ #### 5.3 Create the policy file
156
+
157
+ `origin` MUST be a **single-line** YAML scalar. The frontmatter
158
+ extractor is line-scalar only — block scalars (`origin: |`, `origin: >`)
159
+ are silently truncated to the marker character and the validator
160
+ rejects them. If the user's message is too long for one line, write a
161
+ short summary in `origin` and put the verbatim quote in a body section
162
+ called `## Captured From`.
163
+
164
+ ```bash
165
+ curl -sS -X PUT http://localhost:8321/api/context/rules/policies/<slug> \
166
+ -H 'Content-Type: application/json' \
167
+ -d @- <<'JSON'
168
+ {"content":"---\ntype: rule\nkind: policy\nowner: agent\nupdated: 2026-04-24\nslug: <slug>\nstatus: active\ncreated_at: 2026-04-24\ncreated_via: dm\norigin: \"User DM 2026-04-24T14:30Z: <one-line summary or short quote>\"\nlinked:\n routine: <slug>\n dossier: <topic>\ntemplate_version: 1\n---\n# <Title>\n\n## Why\n<one short paragraph>\n\n## How\n1. …\n\n## Source of Truth\n- Authoritative: …\n- Local cache: dossiers/<topic>.md\n\n## Captured From\n> <verbatim DM quote, only when too long for the origin line>\n\n## Notes\n- …\n"}
169
+ JSON
170
+ ```
171
+
172
+ The global FS-watch reconciler picks this up within ~1s and the policy
173
+ appears in `context-index.md` automatically. The policy-index
174
+ reconciler also fires on the same FS event (chained off the same
175
+ debounce), so `rules/policies/_index.md` and `rules/management.md`'s
176
+ `## Active Policies` section refresh within ~10 s — no manual PATCH
177
+ needed.
178
+
179
+ The `linked:` mapping uses nested YAML for human/LLM readability. The
180
+ daemon's frontmatter validator does not parse nested keys, but the
181
+ **policy-index reconciler does** — it reads `linked.routine` to
182
+ populate the cadence column (by reading the routine file's `cron`
183
+ field) and `linked.dossier` for the dossier column. Keep the slug
184
+ values aligned with the filenames you created at 5.1 / 5.2 so the
185
+ reconciler can resolve them.
186
+
187
+ #### 5.4 _(no manual step required)_
188
+
189
+ `rules/policies/_index.md` is auto-maintained by the daemon's
190
+ policy-index reconciler — it re-renders within ~10 s of step 5.3's
191
+ write. Same for the `## Active Policies` section in
192
+ `rules/management.md`. Do not PATCH or PUT either path manually; doing
193
+ so just races the reconciler and creates snapshot churn.
194
+
195
+ If you need to confirm the index is up to date before replying to the
196
+ user, GET `rules/policies/_index` after a short wait. The reconciler's
197
+ last-run record lives at runtime_state key
198
+ `reconciler.policy_index.last_run` for diagnostics.
199
+
200
+ ### Step 6 — Confirm to the user (one DM)
201
+
202
+ Use the `notify` skill (or reply-in-channel, depending on flow) with a
203
+ concise summary:
204
+
205
+ - policy slug + cadence
206
+ - what was created (dossier / routine / policy / index)
207
+ - how to pause it later (e.g. "say 'pause the morning finance check'")
208
+
209
+ ### Step 7 — Audit
210
+
211
+ Each PUT/PATCH at steps 5.1-5.4 is Autonomous (`risk-classifier.ts`,
212
+ post-Notify-abolition). The route layer snapshots the prior file
213
+ content into `md_file_snapshots` (trigger `api_put` / `api_patch` /
214
+ `api_delete`) so the skill's rollback path can recover pre-edit state,
215
+ and every write is logged to `agent_actions` for the user's on-demand
216
+ retrospective via `GET /api/agent/actions`. Do **not** call any extra
217
+ audit endpoint — the durable trail is already produced.
218
+
219
+ ## Pause / resume / remove (best-effort fan-out)
220
+
221
+ Identify the policy slug from the user's wording. If ambiguous, list
222
+ the active policies first and ask.
223
+
224
+ ### Pause
225
+
226
+ 1. GET the policy file, flip the frontmatter `status: paused` and
227
+ `updated: <today>`, PUT back. (The frontmatter parser is
228
+ line-scalar so a per-field PATCH section call would not target a
229
+ frontmatter key — always GET-merge-PUT for frontmatter edits.)
230
+ 2. If `linked.routine` is set: GET `routines/custom/<slug>`, flip
231
+ frontmatter `enabled: false`, PUT back. The reload hook flips the
232
+ cron job off automatically.
233
+
234
+ The policy-index reconciler picks the change up on the FS event and
235
+ re-renders both `_index.md` and the management.md section within
236
+ ~10 s. Do not PATCH them manually.
237
+
238
+ If step 2 fails after step 1 succeeded, **attempt to roll back step 1**
239
+ (`status` back to `active`). If the rollback itself fails, report the
240
+ partial state to the user and tell them which file is in which state.
241
+
242
+ ### Resume
243
+
244
+ Same fan-out, with `status: active` and `enabled: true`.
245
+
246
+ ### Remove
247
+
248
+ 1. GET the policy file, flip frontmatter `status: removed` and
249
+ `updated: <today>`, PUT back.
250
+ 2. If `linked.routine` is set: `DELETE
251
+ /api/context/routines/custom/<slug>` (whitelisted).
252
+
253
+ The reconciler moves the row from `## Active` to `## Removed`
254
+ automatically — the `removedAt` cell is read from the policy file's
255
+ `updated` field, which step 1 set to today.
256
+
257
+ The policy file itself is **kept for history** — DELETE on `rules/*`
258
+ is intentionally not whitelisted (see MANAGEMENT-POLICY-CAPTURE-PLAN
259
+ §5.1).
260
+
261
+ ## What this skill does NOT do
262
+
263
+ - Does NOT touch `rules/management.md` body sections (Source of Truth
264
+ table, Notification Rules, Schedule, etc.). Those are wizard-only.
265
+ - Does NOT create rows in the `recurring_schedules` DB table — defer to
266
+ `routines/custom/` for cron, which gives the user a visible MD file
267
+ to edit.
268
+ - Does NOT migrate existing custom routines into policy files
269
+ retroactively. Migration is a separate one-time operation.
270
+
271
+ ## Cross-skill pointers
272
+
273
+ - **Need a one-off wake-up?** Use `schedule` (`/api/schedule` or
274
+ `/api/schedule/dm`) — no policy file needed.
275
+ - **Need a recurring DB-driven task with no recorded `## Why`?** Use
276
+ `schedule`'s `/api/recurring-schedules`.
277
+ - **Tone / voice / language preference?** Use `user-profile`'s
278
+ character path (`PATCH /api/config/character`), NOT a policy file.
279
+
280
+ ## API summary
281
+
282
+ All writes go through the standard `/api/context/*` chokepoint. No new
283
+ endpoint exists for this skill.
284
+
285
+ | Verb + path | Used in |
286
+ |---|---|
287
+ | `GET /api/context/rules/policies/_index` | Step 1 (read summary) |
288
+ | `GET /api/context/list/rules` (entries prefixed `policies/` are policy files) | Step 1 (authoritative) |
289
+ | `GET /api/context/rules/policies/<slug>` | Read before pause/resume/remove |
290
+ | `PUT /api/context/dossiers/<topic>` | Step 5.1 (if new dossier) |
291
+ | `PUT /api/context/routines/custom/<slug>` | Step 5.2 (if scheduling) |
292
+ | `PUT /api/context/rules/policies/<slug>` | Step 5.3 |
293
+ | `PATCH /api/context/rules/policies/<slug>` | Pause / resume / remove (frontmatter via GET-merge-PUT) |
294
+ | `DELETE /api/context/routines/custom/<slug>` | Remove only |
295
+
296
+ `rules/policies/_index.md` and the `## Active Policies` section in
297
+ `rules/management.md` are written by the daemon's policy-index
298
+ reconciler — they are NOT in the agent's write surface for this
299
+ skill.
300
+
301
+ Frontmatter validation enforces `kind: policy`, `owner: agent`, and the
302
+ slug rules above. Malformed writes return 422 with the failing field —
303
+ surface that text to the user verbatim rather than retrying blindly.
304
+
305
+ ## Policy file section shape (auto-curated)
306
+
307
+ <!-- CURATION:knowledge_layout id="policy-file-shape" -->
@@ -0,0 +1,13 @@
1
+ {
2
+ "version": 1,
3
+ "sections": [
4
+ {
5
+ "id": "policy-file-shape",
6
+ "kind": "knowledge_layout",
7
+ "anchor": "<!-- CURATION:knowledge_layout id=\"policy-file-shape\" -->",
8
+ "human_label": "Policy file section shape",
9
+ "description": "Required sections inside rules/policies/<slug>.md and what each holds",
10
+ "scope_paths": ["rules/policies/*.md"]
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "kind": "knowledge_layout",
3
+ "files": [
4
+ {
5
+ "path": "rules/policies/*.md",
6
+ "purpose": "Durable management policy capturing why a recurring rule exists, how it runs, and where data lands",
7
+ "sections": [
8
+ { "heading": "## Why", "contains": "one short paragraph stating the motivation behind the policy" },
9
+ { "heading": "## How", "contains": "ordered steps describing what the policy does on each fire" },
10
+ { "heading": "## Source of Truth", "contains": "authoritative reference plus the local cache file under dossiers" },
11
+ { "heading": "## Captured From", "contains": "verbatim DM quote when the origin line is too short to hold it" },
12
+ { "heading": "## Notes", "contains": "operational notes, exceptions, manual override history" }
13
+ ]
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,202 @@
1
+ ---
2
+ name: management-task-modify
3
+ description: Change cadence, intent, or output path on an existing managed task (`mt_<n>`) from a DM — "move daily Zoom check to 9am", "switch Gmail triage to Mondays". Owns PATCH on §B rows. SKIP for new registrations, stops, or app changes.
4
+ when_to_use: User wants to keep a managed task running but adjust its cadence / intent / output path. SKIP for new registrations (`management-task-register`), stops (`management-task-stop`), or one-off run-now (`POST /api/managed-tasks/:id/run-now`).
5
+ allowed-tools:
6
+ - Bash(curl *)
7
+ - Bash(jq *)
8
+ - Read
9
+ ---
10
+
11
+ # Modify a Managed Task
12
+
13
+ Changes the cadence, intent, or `Output path` on an existing
14
+ `mt_<n>` row in place. The `mt_id` is preserved across modifications
15
+ so historical references in `agent_actions` and
16
+ `_activity/<source>.md` remain unambiguous (§10.2).
17
+
18
+ ## When to use
19
+
20
+ The user clearly references an existing recurring commitment and asks
21
+ to change its **cadence**, **intent text**, or **output path**:
22
+
23
+ - "Move the Zoom check to 9am instead of 10am"
24
+ - "Switch the Gmail invoice triage to every Monday"
25
+ - "Send Drive receipts to `finance/receipts/` instead of `personal/receipts/`"
26
+ - "Rename the intent on `mt_42` to `Zoom recordings → meeting notes`"
27
+
28
+ ## When NOT to use
29
+
30
+ | Shape | Use instead |
31
+ |---|---|
32
+ | New recurring commitment | `management-task-register` |
33
+ | User wants to stop / pause it | `management-task-stop` (no soft-pause; hard-delete + re-register if they want to resume) |
34
+ | User wants to run once off-schedule | `POST /api/managed-tasks/<id>/run-now` |
35
+ | User wants to change which **app** an existing task targets | `management-task-stop` then `management-task-register` (different connector ⇒ different commitment) |
36
+ | User wants to change the SoT for a category | `PUT /api/sot-bindings` (A-section flow) |
37
+
38
+ A change of `app` is a different commitment — stop and re-register
39
+ rather than mutating the row, because the connector probe must run
40
+ fresh and the entity-mirror associations may differ.
41
+
42
+ ## Algorithm (mirror of design 21 §10.2)
43
+
44
+ ### Step 1 — Locate the row
45
+
46
+ Read the registry and find the row the user means. If the user named
47
+ an `mt_<n>` directly, fetch by id; otherwise dedup by `(app, cadence,
48
+ intent)` the same way `management-task-register` does.
49
+
50
+ ```bash
51
+ # By id when the user said "mt_42":
52
+ curl -s "http://localhost:8321/api/managed-tasks/mt_42" | jq .item
53
+
54
+ # By app fuzzy lookup:
55
+ curl -s "http://localhost:8321/api/managed-tasks" | jq '.items[] | select(.app_normalized == "zoom")'
56
+ ```
57
+
58
+ GET-by-id wraps the row in `{item:<row>}`; the list returns
59
+ `{items:[…], count:N}`.
60
+
61
+ If no row matches, DM:
62
+
63
+ > No managed task for `<app>` is registered. Want me to register one?
64
+
65
+ If multiple rows could plausibly match, list them with id + cadence +
66
+ intent and ask the user to pick. Stop until they reply.
67
+
68
+ ### Step 2 — Diff the requested change
69
+
70
+ Map the user's request to one or more of these fields:
71
+
72
+ | User request | PATCH field | Notes |
73
+ |---|---|---|
74
+ | "9am instead of 10am" / "every Monday" | `cadence` + `recurrenceRule` (send both together) | Same `recurrenceRule` shape as `management-task-register` Step 5; only `daily`/`weekly`/`monthly` are representable |
75
+ | "Rename intent" / "describe it as `<text>`" | `intent` | ≤ 200 chars, NFC, no `\n`, no `\|` |
76
+ | "Send to `<dir>/`" | `output_path` | Validate against §9.3 (`<domain>/<type-plural>/`, trailing `/`, no `..`); send `null` to clear |
77
+
78
+ If the request implies **app change**, stop and route the user to
79
+ "stop + re-register" (Step 1 disambiguator above).
80
+
81
+ ### Step 3 — Confirm with the user before mutating (Notify tier)
82
+
83
+ PATCH on a managed task is **Notify tier** (§13.1). DM the user
84
+ verbatim with the proposed change and wait for an explicit yes:
85
+
86
+ > `mt_42` Zoom check — change cadence from `daily 10:00 (Asia/Tokyo)`
87
+ > to `daily 09:00 (Asia/Tokyo)`?
88
+
89
+ Only after the user confirms do you issue the PATCH. If they decline
90
+ or amend, restart at Step 2 with the new shape.
91
+
92
+ When the user's confirmation also implies a different output path
93
+ ("…and write into `work/meetings/agendas/`"), include both fields in
94
+ one PATCH so the audit row reflects the user's actual intent in a
95
+ single transition.
96
+
97
+ ### Step 4 — PATCH /api/managed-tasks/:id
98
+
99
+ ```bash
100
+ curl -sS -X PATCH http://localhost:8321/api/managed-tasks/mt_42 \
101
+ -H 'Content-Type: application/json' \
102
+ -d @- <<'JSON'
103
+ {
104
+ "cadence": "daily 09:00 (Asia/Tokyo)",
105
+ "recurrenceRule": {
106
+ "frequency": "daily",
107
+ "time": "09:00",
108
+ "timezone": "Asia/Tokyo"
109
+ }
110
+ }
111
+ JSON
112
+ ```
113
+
114
+ | Field | When to send | Notes |
115
+ |---|---|---|
116
+ | `cadence` + `recurrenceRule` | Cadence change | Send both together so the rendered §B label matches the executable schedule. PATCH body must include at least one mutable field; an empty body returns `validation_error`. |
117
+ | `intent` | Intent rename | ≤ 200 chars; trimmed + NFC at the boundary |
118
+ | `output_path` | Output relocation | `<domain>/<type-plural>/` per §9.3; `null` clears it (back to "first run decides") |
119
+
120
+ `app` / `app_normalized` / `last_run_at` / `last_result` /
121
+ `consecutive_failures` are NOT mutable through this PATCH. Run-result
122
+ writes go through the internal `/run-result` route used by
123
+ `scheduled-managed-task`; app rename goes through the dedicated
124
+ `POST /api/managed-tasks/:id/rename-app` (Step 1 disambiguator above
125
+ already routes that case to "stop + re-register" for safety).
126
+
127
+ The server-side transaction:
128
+
129
+ a. UPDATEs `recurring_schedules` (if `recurrenceRule` changed),
130
+ b. UPDATEs `managed_tasks.{intent,cadence,output_path,updated_at}`,
131
+ c. re-renders `rules/management.md` from DB (locked + snapshotted),
132
+ d. INSERTs `agent_actions` (`action_type='management_task.modified',
133
+ detail={changed, from, to}`).
134
+
135
+ The response is `{status:"updated", item:<ManagedTask>, render_status}`.
136
+
137
+ The `mt_id`, `last_run_at`, `last_result`, and
138
+ `consecutive_failures` are preserved across the PATCH — history is
139
+ continuous (§10.2).
140
+
141
+ A cadence change cancels any in-flight `agent_schedule` row tied to
142
+ the old cron; the new cron takes effect from the next eligible slot.
143
+ Do not separately DELETE `agent_schedule` items — the daemon owns
144
+ that.
145
+
146
+ **Output-path relocation does NOT move existing entity files.** Past
147
+ entities stay where they were written. If the user wants
148
+ re-organization, stop the task, move the entity files manually (or
149
+ ask the user to), and re-register.
150
+
151
+ ### Step 5 — Confirm to user
152
+
153
+ One DM, persona-tone (`notify` skill discipline applies). Read the
154
+ resolved fields from the PATCH response — do NOT echo what you sent
155
+ in case the daemon normalized something:
156
+
157
+ > Updated `mt_42` Zoom check — now daily 09:00 JST. Next run 2026-12-05 09:00 JST.
158
+
159
+ If the PATCH only changed `intent` or `output_path` (no cadence
160
+ shift), do not announce a "next run" line — the next firing is
161
+ unchanged.
162
+
163
+ ## Error envelope
164
+
165
+ | HTTP | `error` | What to do |
166
+ |---|---|---|
167
+ | 400 | `invalid_id` | The `:id` segment didn't match `^mt_[1-9]\d*$`; the user typed the id wrong — ask them to repeat |
168
+ | 400 | `validation_error` | Body has Zod `details`; pin the failing path (e.g. `recurrenceRule.daysOfWeek` not allowed for `daily`) and ask for a fix |
169
+ | 404 | `not_found` | DM "I don't have an `mt_<id>` to modify"; offer to register one |
170
+ | 5xx | `internal_error` | Surface `body.message` if present; advise `aitne logs` |
171
+
172
+ The daemon does not currently emit `cron_too_tight` (the recurrence
173
+ schema only accepts daily/weekly/monthly — sub-daily is impossible),
174
+ nor `cadence_partial` (the recurrence rule is one structured field, so
175
+ there is no partial-cadence shape to reject). If a future schema gain
176
+ adds them, surface them verbatim.
177
+
178
+ ## What this skill does NOT do
179
+
180
+ - Does NOT mutate `app` — that is a different commitment, stop +
181
+ re-register.
182
+ - Does NOT pause / disable a task — there is no soft-pause; stop +
183
+ re-register if the user wants a hiatus.
184
+ - Does NOT touch §A (SoT bindings) or §C (Active Policies).
185
+ - Does NOT PUT `rules/management.md` directly. The daemon owns the
186
+ file write.
187
+ - Does NOT migrate entity files when `output_path` changes; only
188
+ future runs honor the new path.
189
+ - Does NOT auto-confirm "this looks right" — Notify-tier means a real
190
+ user-facing confirmation in the user's preferred language.
191
+
192
+ ## API summary
193
+
194
+ | Verb + path | Used in |
195
+ |---|---|
196
+ | `GET /api/managed-tasks` | Step 1 (lookup by app/cadence) |
197
+ | `GET /api/managed-tasks/:id` | Step 1 (lookup by id) |
198
+ | `PATCH /api/managed-tasks/:id` | Step 4 (Notify-tier) |
199
+ | `POST /api/notify` | Step 5 (user-facing confirmation) |
200
+
201
+ The PATCH writes one `agent_actions` row and snapshots the file —
202
+ do NOT post a separate audit event yourself.