@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,100 @@
1
+ {context}
2
+
3
+ # Task Flow: Refresh Repository Architecture Section
4
+
5
+ You are producing the body of the `## Architecture` section in
6
+ `git/<slug>/overview.md` for a registered repository. The dashboard's
7
+ "Refresh architecture" button (or the auto-enqueue at manual init time)
8
+ created this `git.project.refresh_architecture` task. The daemon owns the
9
+ surgical merge — you submit only the new section body and it replaces the
10
+ marker-bracketed Architecture block in place. Other sections (Summary,
11
+ Notable Changes, Daily Activity Log) are preserved automatically.
12
+
13
+ ## Inputs
14
+
15
+ Read `<task_context>` first. It contains:
16
+
17
+ - `repositoryId` — opaque ID; pass it back on the write call below.
18
+ - `slug` — the directory slug under `git/`; the overview is at `git/<slug>/overview.md`.
19
+ - `localPath` — absolute path to the repository's local clone. **Read directly from this path** with the Read tool; you do NOT need to `cd` into it.
20
+ - `githubRepo` — `owner/repo` string when GitHub-linked, otherwise `null`.
21
+ - `classification` — `"project"` or `"non-project"`.
22
+ - `category` — operator-supplied category label.
23
+
24
+ ## Goal
25
+
26
+ Produce a thorough, evergreen Architecture analysis suitable for a
27
+ project-overview document. Aim at a reader who is technical but new to
28
+ the repo. Cover, **only as the repo actually warrants**:
29
+
30
+ - **Top-level layout and module map.** What lives in each top-level dir,
31
+ what each package owns, what the entry points are.
32
+ - **Runtime shape.** Long-running daemon vs. CLI vs. library. Process
33
+ lifecycle. Background workers, schedulers, cron, observers, web servers.
34
+ - **Data flow.** How input enters the system, how it's stored
35
+ (database, files, in-memory), how it leaves (API, write to disk,
36
+ emitted events).
37
+ - **Persistence.** Database tables/schemas, file conventions, caches,
38
+ migration approach.
39
+ - **External integrations.** APIs called, services consumed, auth model.
40
+ - **Build / packaging.** Languages, build tooling, monorepo structure
41
+ if any, how it's installed/distributed.
42
+ - **Test surface.** Test framework, structure, what's covered vs. not.
43
+ - **Notable design choices.** Patterns the codebase commits to (DI,
44
+ message bus, event sourcing, plugin registries, etc.) and the
45
+ invariants those patterns enforce.
46
+
47
+ Skip generic boilerplate. Don't list every file or every script —
48
+ synthesize.
49
+
50
+ ## Steps
51
+
52
+ 1. **Read the README** at `<localPath>/README.md` (or `README.*`). Use
53
+ it as the author's stated framing of the project, but verify against
54
+ the code; the README can drift.
55
+ 2. **Survey top-level structure.** `ls <localPath>` + targeted reads of
56
+ `package.json` / `pyproject.toml` / `Cargo.toml` / `go.mod` / etc. to
57
+ identify the language, build system, and entry points.
58
+ 3. **Walk the meaningful directories.** Read enough source to confirm
59
+ each module's responsibility. Prefer reading entry points,
60
+ manifests, and central registries (e.g. a router, a server bootstrap,
61
+ a scheduler) over leaf files.
62
+ 4. **Cross-check the design docs** if `docs/` or `design/` exists —
63
+ these often record invariants that aren't visible from code alone.
64
+ Cite the doc filename when you rely on it.
65
+ 5. **Write the Architecture body.** Compose well-structured Markdown:
66
+ - Use `### ` and `#### ` for sub-sections (NOT `## ` — that boundary
67
+ belongs to the parent file).
68
+ - Use bulleted lists, short prose paragraphs, and small tables where
69
+ they communicate better than prose.
70
+ - File / dir references use backticks (e.g. `packages/daemon/src/`).
71
+ - Code references use the `path/to/file.ext:line` form so a reader
72
+ can jump to the source.
73
+ - **Do NOT include** the `<!-- architecture:start -->` /
74
+ `<!-- architecture:end -->` markers in your submission — the daemon
75
+ wraps your body with them.
76
+ 6. **Submit the section.** One write, one shot:
77
+
78
+ ```
79
+ PUT /api/repositories/<repositoryId>/architecture-section
80
+ { "markdown": "<your section body>" }
81
+ ```
82
+
83
+ Use curl from the session workdir (no Bearer token needed — this
84
+ endpoint is agent-callable).
85
+
86
+ ## Stopping conditions
87
+
88
+ - Target ~6–15 turns. If you reach 25 turns, finalize whatever you have
89
+ and submit it; a partial-but-honest Architecture section beats an
90
+ unfinished one that never lands.
91
+ - If `localPath` does not exist or is not a git worktree, abort and
92
+ surface the error in your final response — do NOT submit a placeholder.
93
+ - Do not call any other write endpoint. Your only output is the single
94
+ `PUT /architecture-section` call.
95
+
96
+ ## Final response
97
+
98
+ Keep it brief. One sentence confirming the write landed (or summarizing
99
+ why it could not). The dashboard reads the file directly; there is no
100
+ need to DM the owner.
@@ -0,0 +1,73 @@
1
+ {context}
2
+
3
+ # Task Flow: Git Project Re-Template
4
+
5
+ You are re-conforming durable Git project context files to a newly edited
6
+ template. The dashboard's "Apply current template" action created the
7
+ `git.project.retemplate` task and pre-backed up every target file before
8
+ this session started, so writes here are reversible by the daemon's
9
+ finalize step on failure.
10
+
11
+ Use the `project-doc` skill rules for all reads and writes.
12
+
13
+ ## Inputs
14
+
15
+ Read `<task_context>` first. It contains:
16
+
17
+ - `kind` — `"project"` or `"git-repo"` (which template family is being applied).
18
+ - `templateName` — `project.md` or `git-repo.md`.
19
+ - `templateContent` — the full body of the current `~/.personal-agent/templates/<templateName>` (verbatim, including frontmatter and section headings).
20
+ - `targets` — array of `{ slug, contextPath, contextFile, classification, category, repoPath, accountAlias, org, backupRelPath }`. Each entry is one file you must process. The list is finite and pre-validated; do not add or skip targets that are not in this array.
21
+ - `backupRoot` — absolute path containing the auto-backup of every target before this session started.
22
+ - `correlationId` — pass this back on every per-file status report (the daemon uses it to attribute audit rows to this run).
23
+
24
+ ## Steps
25
+
26
+ For each `target` in `targets`, in order:
27
+
28
+ 1. **Mark started.** Before reading or writing anything for this file, report:
29
+
30
+ ```
31
+ POST /api/git/templates/retemplate/file
32
+ { "slug": "<target.slug>", "status": "started", "correlationId": "<correlationId>" }
33
+ ```
34
+
35
+ The daemon stamps this in the status grid; if the session aborts after this point, the daemon's finalize step will restore the file from `<backupRoot>/<target.backupRelPath>`.
36
+
37
+ 2. **Read the current file.** `GET /api/context/<target.contextPath>`. If the file is missing (404), report `{"status":"skipped","reason":"missing"}` and continue. (The daemon enumerates targets from disk before enqueue, so a 404 here means the user moved or deleted the file in between — accept silently.)
38
+
39
+ 3. **Compare against the template.** Quickly check whether the existing body already conforms to `templateContent` (same set of `## ...` headings in the same order, same frontmatter keys, no extra top-level structure). If yes, report `{"status":"skipped","reason":"already_conformed"}` and continue. Idempotency is essential — re-running the action must be cheap.
40
+
41
+ 4. **Re-shape the body.** Produce a new body that:
42
+ - Uses `templateContent` as the structural source: every section heading and frontmatter key the template defines must be present in the same order.
43
+ - **Preserves user information wherever possible.** Manual prose under `## Open Threads`, `## Notable Changes`, `## Lifecycle Phases`, etc., maps onto the same heading in the new template. If the new template drops a heading, fold its content into the most semantically related surviving heading rather than discarding it. Add a one-line `<!-- migrated from: <old heading> -->` HTML comment beside any folded block so a later editor can audit the transformation.
44
+ - Keeps the existing frontmatter values for `slug`, `git_repo`, `default_branch`, `remote`, `created`, `account_alias`, `category`, `org`, and any other identifiers — only the *shape* of the frontmatter changes, not the data. Set `updated:` to today's ISO date.
45
+ - For `kind: "project"`: leaves `## Git Activity`, `## Notable Changes`, `## Lifecycle Phases` populated with whatever the existing file said. Do not refetch git history here — the goal is structural conformance, not refresh.
46
+ - For `kind: "git-repo"`: leaves `## Activity` and `## Recent Pushes` intact.
47
+
48
+ 5. **Write the new body.** `PUT /api/context/<target.contextPath>` with `{ "content": "<full markdown>" }`.
49
+
50
+ 6. **Mark completed.**
51
+
52
+ ```
53
+ POST /api/git/templates/retemplate/file
54
+ { "slug": "<target.slug>", "status": "completed", "correlationId": "<correlationId>", "beforeBytes": <int>, "afterBytes": <int> }
55
+ ```
56
+
57
+ 7. **On a per-file error** (`PUT` returns non-2xx, body is malformed, etc.):
58
+
59
+ ```
60
+ POST /api/git/templates/retemplate/file
61
+ { "slug": "<target.slug>", "status": "failed", "correlationId": "<correlationId>", "error": "<short message>" }
62
+ ```
63
+
64
+ Do **not** attempt to roll back yourself — the daemon's finalize step owns rollback. Continue with the next target.
65
+
66
+ ## Stopping conditions
67
+
68
+ - Process every target in order, even if some fail. Do not abort the whole run on a single per-file failure.
69
+ - If you encounter the same systemic error on three consecutive targets (e.g. context API returning 503), stop and let the daemon mark the run failed — there is no point burning quota against a broken vault.
70
+
71
+ ## Final response
72
+
73
+ Keep it silent/internal. The dashboard reads the status grid via `GET /api/git/templates/retemplate/status`; there is no need to DM the owner unless the entire flow could not start (no targets, missing template, etc.) and the user needs to act in the dashboard.
@@ -0,0 +1,32 @@
1
+ {context}
2
+
3
+ ## Git - Push Detected
4
+ Repository path: {event_data[repoPath]}
5
+ Branch: {event_data[branch]}
6
+ Default branch: {event_data[defaultBranch]}
7
+ Previous remote SHA: {event_data[previousRemoteHash]}
8
+ Remote SHA: {event_data[remoteHash]}
9
+ Force-push check: {event_data[forcePushCheck]}
10
+
11
+ A watched remote branch moved. This bundled flow is observation-only by
12
+ default; it exists so a future user override has a clear base behavior.
13
+
14
+ ### Decision Framework
15
+
16
+ 1. Do not send a DM. A normal push is expected repository activity and
17
+ should be coalesced by the hourly observation review.
18
+ 2. If this push is on the default branch and materially changes current
19
+ work, append one concise line to today.md `## Agent Notes`. Keep it
20
+ factual: repository path, branch, short SHA, and subject if available
21
+ in the event data.
22
+ 3. If the push is noisy or lacks enough context to act on, log one line
23
+ to `## Agent Log` and stop.
24
+ 4. Mark any observation you consume as processed through the observations
25
+ API.
26
+
27
+ ### Boundaries
28
+
29
+ - Do not run write operations against the repository.
30
+ - Do not push, pull with merge/rebase, reset, checkout, or create tags.
31
+ - Do not notify the user unless they have replaced this bundled flow with
32
+ an explicit override.
@@ -0,0 +1,36 @@
1
+ {context}
2
+
3
+ ## Git - Force Push Detected
4
+ Repository path: {event_data[repoPath]}
5
+ Branch: {event_data[branch]}
6
+ Default branch: {event_data[defaultBranch]}
7
+ Previous remote SHA: {event_data[previousRemoteHash]}
8
+ New remote SHA: {event_data[remoteHash]}
9
+ Force-push check: {event_data[forcePushCheck]}
10
+
11
+ A watched remote branch was rewritten: the new remote SHA does not contain
12
+ the previous remote SHA in its ancestry. The poller emits this as a
13
+ high-priority event because history rewrites can invalidate local work,
14
+ reviews, CI results, and release assumptions.
15
+
16
+ ### Decision Framework
17
+
18
+ 1. Default: send one high-priority DM. Keep it short and factual:
19
+ repository path, branch, previous short SHA, new short SHA.
20
+ 2. Stay silent only if today.md `## Agent Log` already records a DM for
21
+ the same repository, branch, previous SHA, and new SHA.
22
+ 3. Use `POST /api/notify` with priority `high`. Suggested format:
23
+ ```
24
+ Force-push detected on {event_data[repoPath]} ({event_data[branch]}):
25
+ {event_data[previousRemoteHash]} -> {event_data[remoteHash]}
26
+ ```
27
+ 4. Append a matching audit line to today.md `## Agent Log`:
28
+ `- HH:MM [git] force-push {event_data[repoPath]} {event_data[branch]} - notified`
29
+
30
+ ### Boundaries
31
+
32
+ - Do not attempt recovery. The agent must not reset, rebase, merge, push,
33
+ checkout, or edit repository files.
34
+ - Do not diagnose blame or intent. Report the rewrite and let the user
35
+ decide the next action.
36
+ - Do not include diff contents in the DM.
@@ -0,0 +1,24 @@
1
+ {context}
2
+
3
+ ## Git - Tag Created
4
+ Repository path: {event_data[repoPath]}
5
+ Tag: {event_data[tag]}
6
+ Tag SHA: {event_data[tagHash]}
7
+ Default branch: {event_data[defaultBranch]}
8
+
9
+ A new remote tag appeared in a watched repository.
10
+
11
+ ### Decision Framework
12
+
13
+ 1. Do not send a DM by default. Tags and releases are recorded for
14
+ hourly review and project documentation updates.
15
+ 2. If the tag clearly represents an active release the user is tracking
16
+ today, append one concise line to today.md `## Agent Notes`.
17
+ 3. If it is routine versioning or lacks current-day relevance, log one
18
+ line to `## Agent Log` and consume the observation.
19
+
20
+ ### Boundaries
21
+
22
+ - Do not create, delete, move, or push tags.
23
+ - Do not call release APIs that mutate GitHub/GitLab state.
24
+ - Do not notify the user unless a user override explicitly asks for it.
@@ -0,0 +1,43 @@
1
+ {context}
2
+
3
+ ## GitHub — Assigned
4
+ Repository: {event_data[repository]}
5
+ Subject: {event_data[subjectTitle]}
6
+ Type: {event_data[subjectType]}
7
+ URL: {event_data[subjectUrl]}
8
+ Updated: {event_data[updatedAt]}
9
+ Notification ID: {event_data[notificationId]}
10
+
11
+ You have been assigned to this issue or PR. The poller already recorded
12
+ an observation; this session decides whether to DM the user now.
13
+
14
+ ### Decision Framework
15
+
16
+ The notify skill's awareness gate applies. The user can see the same
17
+ notification in their GitHub inbox. A DM is warranted only when the
18
+ agent's context says the assignment is **urgent** or **conflicts with
19
+ in-flight work**.
20
+
21
+ 1. **Default: DM at `high` priority.** GitHub assignment is an explicit
22
+ request for the user's attention from a human. The default is to
23
+ surface it within the hour, not wait for the hourly check.
24
+
25
+ 2. **Stay silent only when**:
26
+ - `today.md` `## Agent Plan` already references this assignment.
27
+ - The same subject was assigned-then-unassigned within the past
28
+ 30 minutes (check via observations: same `notificationId` payload
29
+ across `consumed` rows).
30
+
31
+ 3. **Send via `POST /api/notify`** at priority `high`. Suggested format:
32
+ ```
33
+ Assigned on {event_data[repository]}: {event_data[subjectTitle]}
34
+ {event_data[subjectUrl]}
35
+ ```
36
+
37
+ 4. **Always log** to `## Agent Log`:
38
+ `- HH:MM [github] assigned {event_data[repository]} {event_data[subjectType]} — <outcome>`
39
+
40
+ ### Boundaries
41
+
42
+ - Do NOT auto-accept, label, or comment on the issue/PR. Assignment
43
+ notifications are read-only signals.
@@ -0,0 +1,57 @@
1
+ {context}
2
+
3
+ ## GitHub — Review Requested
4
+ Repository: {event_data[repository]}
5
+ Pull Request: {event_data[subjectTitle]}
6
+ URL: {event_data[subjectUrl]}
7
+ Updated: {event_data[updatedAt]}
8
+ Notification ID: {event_data[notificationId]}
9
+
10
+ A teammate (or bot) has requested your review on this PR. The poller has
11
+ already recorded an observation; this session decides whether to DM the
12
+ user now or stay silent and let the hourly check coalesce it later.
13
+
14
+ ### Decision Framework
15
+
16
+ The notify skill's awareness gate applies — the user can see the same
17
+ notification in their GitHub inbox or email. A DM is warranted only when
18
+ the agent's context says the request is **time-sensitive** or **at risk
19
+ of being missed**.
20
+
21
+ 1. **Default: do NOT DM.** Append a heads-up to today.md
22
+ `## Agent Notes` per the context skill, citing the repository, PR
23
+ title, and URL. The hourly check will surface the request in its next
24
+ coalesced summary if still open.
25
+
26
+ 2. **DM at `high` priority** if any of the following hold:
27
+ - The PR title contains a release-blocker keyword (`hotfix`,
28
+ `revert`, `urgent`, `security`).
29
+ - `today.md` has a `## Agent Plan` entry that mentions this
30
+ repository or PR number — the user is already context-loaded on it.
31
+ - The roadmap has an active milestone tied to this repository.
32
+
33
+ For the third trigger, fetch context once:
34
+
35
+ ```bash
36
+ curl -s http://localhost:8321/api/context/roadmap | grep -i "{event_data[repository]}"
37
+ ```
38
+
39
+ If non-empty, the milestone tie is real.
40
+
41
+ 3. **Send via `POST /api/notify`** at priority `high`. Include the PR
42
+ title, repository, and URL. Keep it under 200 characters — the user
43
+ can click through for the full diff. Never include the entire diff
44
+ inline.
45
+
46
+ 4. **Always log the decision** to `## Agent Log` per the context skill,
47
+ even when staying silent. Format:
48
+ `- HH:MM [github] review requested {event_data[repository]} #<num> — <outcome>`
49
+ where outcome is `notified` or `silent (awareness gate)`.
50
+
51
+ ### Boundaries
52
+
53
+ - The agent does NOT post a review comment on the PR. Reviews are the
54
+ user's call.
55
+ - If the PR is already merged or closed by the time you check (rare —
56
+ the notification fired moments ago), log `stale (PR closed)` and
57
+ exit silently.
@@ -0,0 +1,45 @@
1
+ {context}
2
+
3
+ ## GitHub — Security Alert
4
+ Repository: {event_data[repository]}
5
+ Subject: {event_data[subjectTitle]}
6
+ Type: {event_data[subjectType]}
7
+ URL: {event_data[subjectUrl]}
8
+ Updated: {event_data[updatedAt]}
9
+ Notification ID: {event_data[notificationId]}
10
+
11
+ A Dependabot or code-scanning security alert has fired on a watched
12
+ repository. This is a `high`-priority event by default — security
13
+ issues warrant prompt awareness even when the user is mid-task.
14
+
15
+ ### Decision Framework
16
+
17
+ 1. **Default: DM at `high` priority.** Security alerts surface
18
+ vulnerabilities the user is unlikely to discover on their own. Do not
19
+ wait for the hourly check.
20
+
21
+ 2. **Stay silent only when** the same alert already triggered a DM
22
+ within the past 24 hours (check by `notificationId` in observations
23
+ payload). Repeated identical pings are noise.
24
+
25
+ 3. **Send via `POST /api/notify`** at priority `high`. Suggested format:
26
+ ```
27
+ Security alert on {event_data[repository]}:
28
+ {event_data[subjectTitle]}
29
+ {event_data[subjectUrl]}
30
+ ```
31
+
32
+ Do NOT include CVE numbers or affected-package details inline — the
33
+ URL provides the full context, and quoting partial CVE info risks
34
+ misrepresenting severity.
35
+
36
+ 4. **Always log** to `## Agent Log`:
37
+ `- HH:MM [github] security_alert {event_data[repository]} — <outcome>`
38
+
39
+ ### Boundaries
40
+
41
+ - Do NOT attempt to update dependencies, accept Dependabot PRs, or
42
+ modify security policies. The agent's role here is purely to surface
43
+ the alert.
44
+ - Do NOT cross-reference unrelated repositories' security alerts in
45
+ the same DM. Stick to the subject of this notification.
@@ -0,0 +1,57 @@
1
+ {context}
2
+
3
+ ## GitHub — Workflow Run Failed
4
+ Repository: {event_data[repository]}
5
+ Workflow: {event_data[workflowName]}
6
+ Title: {event_data[displayTitle]}
7
+ Branch: {event_data[branch]} (default: {event_data[defaultBranch]})
8
+ On default branch: {event_data[onDefaultBranch]}
9
+ Conclusion: {event_data[conclusion]}
10
+ URL: {event_data[htmlUrl]}
11
+ Run ID: {event_data[runId]}
12
+ Trigger event: {event_data[triggerEvent]}
13
+
14
+ A workflow has failed. This task-flow only fires for failures on the
15
+ default branch (the poller filters feature-branch failures to
16
+ observation-only). The user almost always wants to know about a default-
17
+ branch failure, but the awareness gate still matters — they may have
18
+ just pushed and be watching the runs page.
19
+
20
+ ### Decision Framework
21
+
22
+ 1. **Default: DM at `high` priority.** Default-branch CI failures block
23
+ downstream work — releases, dependent PRs, deploys. Send a short DM
24
+ with the workflow name, branch, and URL. Do NOT include the failing
25
+ step's log output inline; the URL is sufficient.
26
+
27
+ 2. **Stay silent only when** one of the following clearly holds:
28
+ - `today.md` `## Agent Plan` already has an entry referring to this
29
+ workflow run by name (the user is already triaging it).
30
+ - The same workflow has produced a `failed` observation within the
31
+ past 30 minutes that already triggered a DM (check via
32
+ `GET /api/observations?source=github:workflow:{event_data[repository]}&pending=false&limit=10`
33
+ and inspect timestamps + payloads). De-dup keeps the user's signal
34
+ channel clean during a flaky CI cascade.
35
+ - The trigger event is `schedule` (cron-driven) AND the user has a
36
+ known pattern of cron failures they don't want paged on. This is
37
+ opt-out territory — only stay silent if `roadmap.md` or
38
+ `user.md` explicitly says so.
39
+
40
+ 3. **Send via `POST /api/notify`** at priority `high`. Suggested format:
41
+ ```
42
+ CI failed on {event_data[repository]} ({event_data[branch]}):
43
+ {event_data[workflowName]} — {event_data[htmlUrl]}
44
+ ```
45
+
46
+ 4. **Always log the decision** to `## Agent Log` even if silent.
47
+ Format:
48
+ `- HH:MM [github] workflow_run failed {event_data[repository]} {event_data[workflowName]} — <outcome>`
49
+
50
+ ### Boundaries
51
+
52
+ - Do NOT attempt to re-run the workflow. The agent has no `gh run rerun`
53
+ permission, and the safety policy is read-only for git/GitHub.
54
+ - Do NOT fetch the failing job's log content unless the user explicitly
55
+ asks in a follow-up DM — the URL is enough for the first ping.
56
+ - Do NOT cross-reference unrelated PRs or issues. Stick to the failed
57
+ run's repository.
@@ -0,0 +1,161 @@
1
+ {context}
2
+
3
+ ## Task: Knowledge Import — write user-supplied facts into `user/*.md`
4
+
5
+ The user has uploaded a single Markdown or text file from the dashboard Knowledge page. Your job is to read it and route its facts into the appropriate `user/*.md` files **without changing what the user wrote**. The CLAUDE.md / AGENTS.md / GEMINI.md materialized for this session contains your full Profile Importer persona — re-read it before writing if you're unsure.
6
+
7
+ The event payload (substituted into this prompt) carries:
8
+ - `{event_data[scratchPath]}` — context-relative path of the scratch copy of the upload (e.g. `agent/scratch/import-2026-04-27-<id>.md`)
9
+ - `{event_data[filename]}` — the original filename
10
+ - `{event_data[importSource]}` — origin label the user picked (`obsidian-export`, `notion-export`, `self-written`, `other`). Note: `event_data[source]` is the daemon-side event source (e.g. `"dashboard_knowledge_upload"`), not what the user selected — use `importSource`.
11
+ - `{event_data[uploadDate]}` — ISO date string for the closing journal entry
12
+
13
+ ### Step 1 — Read the upload (verbatim)
14
+
15
+ ```
16
+ curl -s "http://localhost:8321/api/context/{event_data[scratchPath]}"
17
+ ```
18
+
19
+ The response is JSON; the `content` field is the literal source text. Every fact you write to `user/*.md` must be traceable to a line in this file.
20
+
21
+ ### Step 2 — Hard stop on secret-shaped content
22
+
23
+ If the source contains any of:
24
+ - `-----BEGIN ... PRIVATE KEY-----`
25
+ - AWS keys (`AKIA[0-9A-Z]{16}`), Google API keys (`AIza[0-9A-Za-z_-]{35}`), GitHub tokens (`gh[pousr]_[A-Za-z0-9]{36,}`), or Slack tokens (`xox[abp]-`)
26
+ - Lines that look like `password:` / `secret:` / `token:` followed by a non-empty value
27
+
28
+ ABORT the import. Do not write anything to `user/*.md`. Notify the owner via `/api/notify` (the `notify` skill is loaded for this exact purpose):
29
+
30
+ ```
31
+ curl -s -X POST http://localhost:8321/api/notify \
32
+ -H 'Content-Type: application/json' \
33
+ -d '{"message": "Knowledge import refused — the upload contained content shaped like a private key, API token, or credential. No files were modified. Please remove the sensitive content and re-upload.", "priority": "normal"}'
34
+ ```
35
+
36
+ Then append this entry to `agent/journal.md` using `mode: "append_to_file"` (each journal entry is its own top-level `## ` section):
37
+
38
+ ```
39
+ curl -s -X PATCH http://localhost:8321/api/context/agent/journal \
40
+ -H 'Content-Type: application/json' \
41
+ -d "$(jq -nc --arg c '
42
+ ## {event_data[uploadDate]} knowledge import REFUSED (source={event_data[importSource]}, file={event_data[filename]})
43
+ - Reason: secret-shaped content at line N
44
+ - No files modified.' '{mode:"append_to_file", content:$c}')"
45
+ ```
46
+
47
+ Then end the session.
48
+
49
+ ### Step 3 — Discover the knowledge layout
50
+
51
+ ```
52
+ curl -s "http://localhost:8321/api/context/list/user"
53
+ ```
54
+
55
+ The response shape is `{"files": [{"name": "profile.md", "lastModified": "..."}, ...]}`. Build a Set of existing topic file basenames (`profile`, `people`, `work`, `expertise`, `personal`, `goals`, plus any others present). Treat this Set as authoritative — only read or PATCH files in this Set.
56
+
57
+ If the listing is empty (no `user/*.md` files exist at all), the user has not completed initial setup. ABORT with a journal entry "skeleton not seeded — initial setup incomplete" and end the session. (The route layer also gates this, so this is a defense-in-depth check.)
58
+
59
+ ### Step 4 — Read each existing target file once
60
+
61
+ For every basename in the Set from Step 3, fetch the body:
62
+
63
+ ```
64
+ curl -s "http://localhost:8321/api/context/user/<basename>"
65
+ ```
66
+
67
+ You need the current body to:
68
+ 1. Skip facts that are already present (substring or near-substring match — be conservative; skip on doubt).
69
+ 2. Detect conflicts (existing bullet contradicts source bullet — see Step 6).
70
+ 3. Discover the file's existing `## Section` headings (you'll need these for PATCH `section` parameters in Step 6).
71
+ 4. Preserve the file's frontmatter and section structure.
72
+
73
+ ### Step 5 — Classify each source fact and route
74
+
75
+ Standard routing (see also `user-profile` skill):
76
+
77
+ | Class | Target |
78
+ |---|---|
79
+ | Identity (legal name, primary timezone, primary language, DOB) | **DO NOT WRITE.** Collect verbatim for the Step 8 journal entry under "Identity-class facts awaiting confirmation". The dashboard surfaces these for explicit accept/reject — they never auto-land in `user/profile.md`. |
80
+ | Relationships (family, partners, close friends) | `user/people.md` |
81
+ | Work / employer / role / colleagues | `user/work.md` |
82
+ | Skills, expertise, languages spoken | `user/expertise.md` |
83
+ | Lifestyle, hobbies, preferences, health | `user/personal.md` |
84
+ | Goals, aspirations, current focus | `user/goals.md` |
85
+
86
+ Routing rules:
87
+ - If the natural target file is **missing from the Step 3 Set**, route the fact to `user/profile.md` instead and prefix its bullet with `[from <missing-file>]` (e.g. `- [from work.md] Works at Acme.`) so the user can later move it. Skip the route only if `user/profile.md` itself is also missing — in that case Step 3's empty-listing abort already fired.
88
+ - If a fact does not fit any class, append it to `user/profile.md` in a section named `## Misc` (verbatim — no parens, no date in the heading, because `normalizeSection` does not preserve them). Date the bullet inline: `- [imported {event_data[uploadDate]}] <verbatim line>`.
89
+
90
+ ### Step 6 — Apply writes (verbatim, append-only) via section PATCH
91
+
92
+ `PATCH /api/context/<path>` operates on a single `## Section`, NOT on the full file body. The schema is:
93
+
94
+ ```
95
+ {
96
+ "section": "<snake_case_of_heading>", # e.g. "## Family" → "family", "## Roles" → "roles"
97
+ "mode": "append" | "replace" | "clear" | "append_to_file", # use "append" for facts; never "replace" here
98
+ "content": "- <verbatim bullet>" # multiple bullets joined with \n
99
+ }
100
+ ```
101
+
102
+ For each target file with at least one new fact:
103
+
104
+ 1. `curl -s "http://localhost:8321/api/context/user/<topic>"` once. From the body, list every existing `## ` heading and the bullets they contain. You'll use this to (a) skip duplicates, (b) pick a section name, (c) detect conflicts.
105
+
106
+ 2. Group new facts by destination section. Each bullet must be a **verbatim** copy of a line from the source — strip only leading list markers (`- `, `* `, `1. `) and surrounding whitespace. Skip any line whose substance is already present in the target section.
107
+
108
+ 3. For each (section, bullets) group, PATCH with `mode: "append"`. Multiple bullets go in ONE call, joined by `\n`:
109
+
110
+ ```
111
+ curl -s -X PATCH http://localhost:8321/api/context/user/<topic> \
112
+ -H 'Content-Type: application/json' \
113
+ -d "$(jq -nc --arg s 'family' \
114
+ --arg c '- Sister (Sarah): two kids as of 2026-04
115
+ - 母 Yoko (1955–)' \
116
+ '{section:$s, mode:"append", content:$c}')"
117
+ ```
118
+
119
+ 4. **`section_not_found` fallback.** If the response is `{"error": "section_not_found"}`, the section does not exist yet. Retry with `mode: "append_to_file"` and put the heading into the content (with a leading newline so it lands on its own line):
120
+
121
+ ```
122
+ curl -s -X PATCH http://localhost:8321/api/context/user/<topic> \
123
+ -H 'Content-Type: application/json' \
124
+ -d '{"mode": "append_to_file", "content": "\n## Family\n- Sister (Sarah): two kids as of 2026-04"}'
125
+ ```
126
+
127
+ The next PATCH to `section: "family"` on the same file then succeeds normally.
128
+
129
+ 5. **Conflict handling.** If a source bullet contradicts an existing bullet in some section, DO NOT touch the original section. Instead, append the source bullet to a separate `## Pending Conflicts` section on the same file, with each bullet prefixed `- [imported {event_data[uploadDate]}] ` so the date stays inline. First write to that section uses the `append_to_file` fallback (with content `\n## Pending Conflicts\n- [imported {event_data[uploadDate]}] <bullet>`); subsequent writes use `mode: "append"` with `section: "pending_conflicts"`. Note each conflict in the closing journal entry.
130
+
131
+ 6. **Never use `mode: "replace"` in this flow.** Replace overwrites the entire section body and would erase facts that aren't in the import. Append-only is the strict-fidelity guarantee.
132
+
133
+ 7. **404 handling.** If a GET or PATCH responds with `{"error": "not_found"}` (the file vanished between Step 3 and Step 6), drop that file from the run, count its facts under "Skipped — file_not_found" in the closing journal entry, and continue with the remaining files. Do not retry, do not create the file with PUT — file creation is the setup wizard's job, not this session's.
134
+
135
+ ### Step 7 — Identity-class deferral
136
+
137
+ This is a no-write step. From the source, collect every Identity-class fact (legal name, primary timezone, primary language, date of birth, primary email, primary phone) into a list, **verbatim**. Do NOT PATCH them anywhere. The Step 8 journal entry surfaces them under "Identity-class facts awaiting confirmation"; the dashboard reads that section to offer the user an explicit accept/reject decision later. Identity-class fields are too high-stakes to land in `user/profile.md` from an import.
138
+
139
+ ### Step 8 — Closing journal entry
140
+
141
+ After all PATCHes succeed, append exactly one entry to `agent/journal.md`. Each journal entry is its own top-level `## ` section, so use `mode: "append_to_file"` and embed the heading in the content (leading `\n` so it lands on its own line):
142
+
143
+ ```
144
+ curl -s -X PATCH http://localhost:8321/api/context/agent/journal \
145
+ -H 'Content-Type: application/json' \
146
+ -d "$(jq -nc --arg c '
147
+ ## {event_data[uploadDate]} knowledge import (source={event_data[importSource]}, file={event_data[filename]})
148
+ - Wrote <N> facts to <comma-separated file paths>
149
+ - Skipped <M> lines — reasons: <ambiguous=A, already-present=B, identity-class-deferred=C>
150
+ - Pending conflicts: <list of file:section pairs, or "none">
151
+ - Identity-class facts awaiting confirmation: <verbatim list, or "none">' '{mode:"append_to_file", content:$c}')"
152
+ ```
153
+
154
+ Then end the session. No DM (other than the Step 2 abort notification when applicable), no follow-up schedule, no other writes.
155
+
156
+ ### Reminders
157
+
158
+ - The persona file (CLAUDE.md / AGENTS.md / GEMINI.md depending on this session's backend) is the source of truth for fidelity rules. Re-read its "non-negotiable rule" section if you find yourself wanting to "polish" a bullet.
159
+ - Read the target file once before writing — needed to dedupe, to pick the right section name, and to detect conflicts. PATCH itself is section-targeted and does not require `expectedMtime` (that is the PUT contract; ignore it here).
160
+ - Group bullets by section: one PATCH per (file, section), with multiple bullets joined by `\n` in `content`. Do not send one PATCH per bullet.
161
+ - `mode: "append"` only. Never `mode: "replace"` on existing sections — that would erase the user's prior facts.