@aitne-sh/aitne 0.1.11 → 0.1.13

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 (151) hide show
  1. package/README.md +4 -0
  2. package/agent-assets/agent-profiles/background-task.md +8 -1
  3. package/agent-assets/agent-profiles/routine-fetch-window.md +11 -0
  4. package/agent-assets/agents/evening-review/agent.md +6 -2
  5. package/agent-assets/agents/lesson-maintenance/agent.md +56 -0
  6. package/agent-assets/agents/morning-routine/agent.md +10 -6
  7. package/agent-assets/agents/source-librarian/agent.md +51 -0
  8. package/agent-assets/docs/concepts/agent-day.md +15 -15
  9. package/agent-assets/docs/concepts/auth-health.md +10 -7
  10. package/agent-assets/docs/concepts/backends-and-tiers.md +34 -23
  11. package/agent-assets/docs/concepts/costs-and-quotas.md +10 -10
  12. package/agent-assets/docs/concepts/delegated-mode.md +18 -18
  13. package/agent-assets/docs/concepts/memory-model.md +25 -24
  14. package/agent-assets/docs/concepts/observations.md +27 -19
  15. package/agent-assets/docs/concepts/process-keys.md +25 -26
  16. package/agent-assets/docs/concepts/routines.md +18 -17
  17. package/agent-assets/docs/concepts/safety-and-execution.md +20 -17
  18. package/agent-assets/docs/concepts/safety-model.md +16 -15
  19. package/agent-assets/docs/concepts/skills.md +7 -4
  20. package/agent-assets/docs/features/integrations/browser-history.md +52 -47
  21. package/agent-assets/docs/features/integrations/calendar.md +7 -7
  22. package/agent-assets/docs/features/integrations/git.md +15 -13
  23. package/agent-assets/docs/features/integrations/github.md +12 -10
  24. package/agent-assets/docs/features/integrations/mail.md +47 -45
  25. package/agent-assets/docs/features/integrations/notion.md +15 -11
  26. package/agent-assets/docs/features/integrations/obsidian.md +27 -23
  27. package/agent-assets/docs/features/lifestyle/git.md +7 -8
  28. package/agent-assets/docs/features/lifestyle/reading.md +11 -8
  29. package/agent-assets/docs/features/lifestyle/receipts.md +21 -22
  30. package/agent-assets/docs/features/lifestyle/travel-bookings.md +9 -9
  31. package/agent-assets/docs/features/memory-files/agent-journal.md +12 -10
  32. package/agent-assets/docs/features/memory-files/agent-lessons.md +46 -21
  33. package/agent-assets/docs/features/memory-files/projects.md +13 -14
  34. package/agent-assets/docs/features/memory-files/roadmap.md +16 -15
  35. package/agent-assets/docs/features/memory-files/schedule.md +10 -10
  36. package/agent-assets/docs/features/memory-files/today.md +18 -18
  37. package/agent-assets/docs/features/memory-files/user-profile.md +17 -17
  38. package/agent-assets/docs/features/messaging/bang-commands.md +15 -15
  39. package/agent-assets/docs/features/messaging/dashboard-chat.md +8 -7
  40. package/agent-assets/docs/features/messaging/discord.md +7 -5
  41. package/agent-assets/docs/features/messaging/overview.md +14 -14
  42. package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +12 -12
  43. package/agent-assets/docs/features/messaging/slack.md +9 -8
  44. package/agent-assets/docs/features/messaging/telegram.md +7 -7
  45. package/agent-assets/docs/features/messaging/whatsapp.md +6 -6
  46. package/agent-assets/docs/features/operations/activity-and-conversations.md +9 -9
  47. package/agent-assets/docs/features/operations/approvals.md +13 -12
  48. package/agent-assets/docs/features/operations/backend-routing.md +38 -37
  49. package/agent-assets/docs/features/operations/browser-tasks.md +63 -57
  50. package/agent-assets/docs/features/operations/cost-tracking.md +5 -5
  51. package/agent-assets/docs/features/operations/managed-chromium.md +23 -22
  52. package/agent-assets/docs/features/operations/notifications.md +15 -15
  53. package/agent-assets/docs/features/operations/quiet-hours.md +14 -15
  54. package/agent-assets/docs/features/operations/schedule-approaching.md +16 -14
  55. package/agent-assets/docs/features/routines/activity-scan.md +14 -11
  56. package/agent-assets/docs/features/routines/custom-routines.md +9 -7
  57. package/agent-assets/docs/features/routines/evening-review.md +6 -7
  58. package/agent-assets/docs/features/routines/morning-routine.md +23 -22
  59. package/agent-assets/docs/features/routines/weekly-review.md +57 -51
  60. package/agent-assets/docs/features/wiki/commands.md +28 -22
  61. package/agent-assets/docs/features/wiki/cost-and-approval.md +28 -23
  62. package/agent-assets/docs/features/wiki/dashboard.md +22 -24
  63. package/agent-assets/docs/features/wiki/overview.md +17 -25
  64. package/agent-assets/docs/features/wiki/search.md +15 -17
  65. package/agent-assets/docs/features/wiki/workspaces.md +55 -56
  66. package/agent-assets/docs/getting-started/01-what-is-this.md +4 -5
  67. package/agent-assets/docs/getting-started/02-first-steps.md +12 -13
  68. package/agent-assets/docs/getting-started/03-what-can-this-do.md +7 -7
  69. package/agent-assets/docs/getting-started/04-first-day.md +4 -5
  70. package/agent-assets/docs/glossary.md +21 -19
  71. package/agent-assets/docs/guides/add-a-custom-routine.md +17 -12
  72. package/agent-assets/docs/guides/backup-and-restore.md +19 -16
  73. package/agent-assets/docs/guides/budget-and-cost-for-wiki.md +57 -62
  74. package/agent-assets/docs/guides/build-your-wiki.md +11 -12
  75. package/agent-assets/docs/guides/change-which-model-handles-x.md +30 -28
  76. package/agent-assets/docs/guides/connect-a-new-mail-account.md +30 -29
  77. package/agent-assets/docs/guides/explore-with-trace-and-connect.md +30 -32
  78. package/agent-assets/docs/guides/import-knowledge-file.md +9 -10
  79. package/agent-assets/docs/guides/install-and-run.md +9 -10
  80. package/agent-assets/docs/guides/maintain-wiki-health.md +10 -10
  81. package/agent-assets/docs/guides/migrate-machines.md +16 -14
  82. package/agent-assets/docs/guides/multiple-wikis-for-multiple-domains.md +12 -13
  83. package/agent-assets/docs/guides/pause-the-agent.md +25 -25
  84. package/agent-assets/docs/guides/reinstall-cleanly.md +13 -12
  85. package/agent-assets/docs/guides/setup-wizard.md +10 -12
  86. package/agent-assets/docs/guides/switch-default-backend.md +9 -9
  87. package/agent-assets/docs/guides/use-an-existing-obsidian-vault.md +9 -11
  88. package/agent-assets/docs/pages/activity.md +76 -0
  89. package/agent-assets/docs/pages/agents.md +78 -0
  90. package/agent-assets/docs/pages/analytics.md +70 -0
  91. package/agent-assets/docs/pages/browser.md +73 -0
  92. package/agent-assets/docs/pages/chat.md +67 -0
  93. package/agent-assets/docs/pages/connections.md +78 -0
  94. package/agent-assets/docs/pages/git.md +73 -0
  95. package/agent-assets/docs/pages/knowledge.md +75 -0
  96. package/agent-assets/docs/pages/overview.md +90 -0
  97. package/agent-assets/docs/pages/reading.md +65 -0
  98. package/agent-assets/docs/pages/settings.md +77 -0
  99. package/agent-assets/docs/pages/tasks.md +74 -0
  100. package/agent-assets/docs/pages/wiki.md +73 -0
  101. package/agent-assets/docs/reference/api.md +18 -17
  102. package/agent-assets/docs/reference/cli-commands.md +13 -10
  103. package/agent-assets/docs/reference/config.md +40 -35
  104. package/agent-assets/docs/reference/disallowed-tools.md +18 -17
  105. package/agent-assets/docs/reference/keyboard-shortcuts.md +6 -8
  106. package/agent-assets/docs/reference/knowledge-layout.md +10 -10
  107. package/agent-assets/docs/reference/process-keys.md +20 -22
  108. package/agent-assets/docs/reference/skills.md +18 -16
  109. package/agent-assets/docs/troubleshooting/auth-failed.md +13 -11
  110. package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +10 -10
  111. package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +26 -24
  112. package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +8 -9
  113. package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +19 -18
  114. package/agent-assets/docs/troubleshooting/observation-not-detected.md +14 -15
  115. package/agent-assets/docs/troubleshooting/quota-exhausted.md +28 -26
  116. package/agent-assets/docs/troubleshooting/wiki-ingest-full-blocked.md +35 -34
  117. package/agent-assets/docs/troubleshooting/wiki-write-failed.md +21 -24
  118. package/agent-assets/playbooks/markdown-note.md +43 -0
  119. package/agent-assets/playbooks/monitoring.md +29 -0
  120. package/agent-assets/playbooks/research.md +47 -0
  121. package/agent-assets/skills/agent-create/SKILL.md +71 -32
  122. package/agent-assets/skills/agent-create/references/prompt-frame-extended.md +132 -0
  123. package/agent-assets/skills/agent-create/references/prompt-frame.md +125 -0
  124. package/agent-assets/skills/background-task/SKILL.md +13 -8
  125. package/agent-assets/skills/background-task-reply/SKILL.md +2 -2
  126. package/agent-assets/skills/board/SKILL.md +92 -0
  127. package/agent-assets/skills/browser-history/SKILL.md +3 -3
  128. package/agent-assets/skills/browser-history-respond/SKILL.md +3 -3
  129. package/agent-assets/skills/browser-task/SKILL.md +4 -2
  130. package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +2 -1
  131. package/agent-assets/skills/schedule/SKILL.md +21 -18
  132. package/agent-assets/skills/schedule/references/batch.md +1 -1
  133. package/agent-assets/skills/schedule/references/model-selection.md +1 -1
  134. package/agent-assets/skills/schedule/references/prompt-frame.md +125 -0
  135. package/agent-assets/skills/sources/SKILL.md +68 -0
  136. package/agent-assets/skills/sources/curation.json +21 -0
  137. package/agent-assets/skills/sources/seeds/filing-rules.seed.json +25 -0
  138. package/agent-assets/skills/sources/seeds/source-collections.seed.json +20 -0
  139. package/agent-assets/skills/task/SKILL.md +82 -0
  140. package/agent-assets/task-flows/background_task.md +29 -3
  141. package/agent-assets/task-flows/message.received.dm.md +1 -1
  142. package/agent-assets/task-flows/routine.activity_scan.md +17 -2
  143. package/agent-assets/task-flows/routine.evening_review.md +72 -11
  144. package/agent-assets/task-flows/routine.fetch_window.md +21 -0
  145. package/agent-assets/task-flows/routine.monthly_review.md +3 -1
  146. package/agent-assets/task-flows/routine.morning_routine_today.md +26 -7
  147. package/agent-assets/task-flows/routine.source_maintenance.md +50 -0
  148. package/agent-assets/task-flows/scheduled.dm.md +29 -16
  149. package/agent-assets/templates/_manifest.json +1 -0
  150. package/agent-assets/templates/knowledge/sources/_index.md +19 -0
  151. package/package.json +4 -4
@@ -23,6 +23,32 @@ user's explicit rulebook intent. For ad-hoc deadline or surprise nudges,
23
23
  the surfacing event handler that discovered the item — not this routine —
24
24
  is the right vehicle.
25
25
 
26
+ **Session constraints & turn economy** (apply at every step):
27
+ - This session has **no calendar or external-connector access**.
28
+ "Prepare tomorrow" means updating the `state/today.md` ## Handoff
29
+ `### Tomorrow` section in Step 1 — that is the entire contract. Do
30
+ NOT attempt a calendar or observations "tomorrow preview"; no tool
31
+ in this session can serve it, and probing for one wastes a turn.
32
+ If Handoff needs upcoming-event context, the injected
33
+ `<calendar_events_3d>` block already carries the coming days'
34
+ events — read it directly.
35
+ - Operate in as few turns as possible: consolidate tool calls, do not
36
+ narrate routine actions, and never re-derive facts already in your
37
+ context. Issue independent read-only GETs (e.g. the Step 0
38
+ observations drain) together in a single turn as parallel tool
39
+ calls. The one exception is rebuild discipline: a GET that feeds a
40
+ `mode=replace` PATCH (e.g. the Step 4 lesson-store reads) must be
41
+ fresh — keep it adjacent to its write, never batched up front.
42
+ - Injected context blocks (`<roadmap>`, `<today>`, `<user>`,
43
+ `<feedback_worksheet>`, …) are already in your prompt — never GET a
44
+ file merely to read what is injected. GET fresh only immediately
45
+ before a rebuild-and-replace write.
46
+ - Prose writes to `journal/agent.md` use
47
+ `PATCH /api/context/journal/agent` with the body
48
+ `{"mode":"append_to_file","content":"..."}` — `append_to_file`
49
+ appends at end-of-file and takes **no** `section` field
50
+ (`mode:"append"` without a `section` is rejected with 400).
51
+
26
52
  ### Step 0 — Read today's mail outcomes
27
53
 
28
54
  The pre-pass fetcher session (`routine.fetch_window`) ran ahead of you
@@ -74,6 +100,16 @@ are NOT this routine's job anymore. This step only carries the two
74
100
  substeps that genuinely need an LLM in the loop: promote-on-resolution
75
101
  and Review-date fire.
76
102
 
103
+ **Skip-gate (check the injected roadmap before locking).** Read
104
+ `## Long-term Plans` from the `<roadmap>` block already in your
105
+ prompt (it is injected verbatim). If it is empty, or it has no entry
106
+ that resolved to a concrete date today (2a) and no entry whose
107
+ `Review:` date is on or before today (2b, ignoring
108
+ `Review: [noreview]`), skip Step 2 entirely — do NOT acquire the
109
+ lock and do NOT GET the roadmap. An entry added mid-evening simply
110
+ waits for tomorrow's review — the same 24-hour tolerance the
111
+ 409-conflict path below already accepts.
112
+
77
113
  **Write-lock handling.** `<roadmap_write_lock_id>` is NOT injected for
78
114
  evening_review, so acquire the lock explicitly before the first PATCH:
79
115
  `POST /api/context/lock/roadmap` → read back `lockId`. On 409 (a
@@ -238,6 +274,13 @@ worksheet's `decision` and `rank` verbatim. If the block is absent, skip this
238
274
  step entirely. Like Steps 1–3 it is internal bookkeeping and emits no
239
275
  user-facing output.
240
276
 
277
+ When the worksheet carries an `<outcome_rollup>` block (per-notification-type
278
+ reaction counts over the last week), weigh it while judging promotions and
279
+ demotions: a high `correction_rate` on an action type argues for demoting
280
+ lessons that push that behaviour and supports candidates that curb it. Never
281
+ treat `ignored` as rejection — it is engagement-coverage only — and never
282
+ reward sheer notification volume.
283
+
241
284
  4a. **Lesson-store scopes** — process **every** `<scope … mode="lessons">` in the
242
285
  worksheet, writing each to the `store=` path it declares: the global `agent`
243
286
  scope (`store="policies/agent-lessons.md"`) and any per-agent
@@ -253,24 +296,42 @@ user-facing output.
253
296
  intent. If found, bump its `ev=` by `weighted_ev` (rounded to a whole
254
297
  number), refresh `last=` to today, raise `conf`, and tighten the wording.
255
298
  If not, add a new **active** bullet:
256
- `- [<today>] <directive> <!-- ev=<round(weighted_ev), min 1> kind=<kind> src=<src> conf=<conf> last=<today> -->`
257
- (`src`/`conf` come from the candidate; use the candidate's `kind=` when
258
- present, otherwise infer it from the directive; `kind`
259
- preference|correction|do-more|do-less|constraint).
299
+ `- [<today>] <directive> <!-- ev=<round(weighted_ev), min 1> kind=<kind> src=<src> conf=<conf> cf=<cf0> last=<today> -->`
300
+ (`src`/`conf` come from the candidate; `cf=` copies the candidate's
301
+ `cf0=` for a new bullet or the existing lesson's `cf=` verbatim — never
302
+ invent a value, the daemon re-stamps it deterministically after your
303
+ write; use the candidate's `kind=` when present, otherwise infer it from
304
+ the directive; `kind` ∈ preference|correction|do-more|do-less|constraint).
305
+ - `decision="promote"` with a `contradicts_ranks=` attribute → the candidate
306
+ cleared the anti-whiplash bar against the lessons at those ranks.
307
+ Adjudicate: **supersede** (mark each contradicted lesson provisional and
308
+ promote the candidate), **merge** (rewrite one bullet to cover both,
309
+ drop the other), or **keep-distinct** (the conflict is context-scoped —
310
+ keep both, scoping each bullet's wording so they cannot collide).
260
311
  - `decision="hold-provisional"` with `reason="below-threshold"` → if it
261
312
  matches an existing lesson's intent, bump that lesson's `ev`; otherwise add
262
313
  the bullet with a trailing `<!-- provisional -->` marker (stored, not yet
263
314
  injected — it promotes once corroboration reaches the threshold).
315
+ - `decision="hold-contradiction"` → the candidate contradicts an
316
+ established lesson (see `contradicts_ranks=`) and has NOT yet cleared the
317
+ higher evidence bar. Store it as a provisional bullet; do **not**
318
+ supersede, weaken, or reword the lessons it contradicts.
264
319
  - `decision="hold-provisional"` with `reason="ignored-non-initiating"` →
265
320
  silence never *starts* a lesson. Only use it to bump the `ev` of an
266
321
  existing matching lesson; if none matches, write nothing for it.
267
- - A newer `correction` that contradicts an active lesson **supersedes** it:
268
- drop the stale bullet in the same rebuild so a changed mind leaves no
269
- stale guidance.
270
- - **Staleness prune** (§4 step 7): drop any existing lesson the worksheet
271
- marks `stale="true"` (its `last=` is past the staleness horizon and it is
272
- not a `constraint`) unless a fresh candidate re-reinforces it this pass —
273
- a `constraint` is durable and is never stale-pruned.
322
+ - A newer explicit `correction` that contradicts an active lesson
323
+ **supersedes** it: drop the stale bullet in the same rebuild so a changed
324
+ mind leaves no stale guidance (a user correction always wins — the
325
+ contradiction guard applies only to inferred candidates).
326
+ - **Expiration verdicts** (graduated, reversible): honour each existing
327
+ lesson's `action=` attribute verbatim `action="demote"` append
328
+ `<!-- provisional -->` to the bullet unless a fresh candidate
329
+ re-reinforces it this pass; `action="archive"` → drop the bullet (its raw
330
+ evidence stays in feedback_signals); a re-reinforced provisional lesson
331
+ whose bumped `ev` now meets the threshold → remove its provisional
332
+ marker. `action="keep"` (and every `constraint`) stays untouched. The
333
+ daemon enforces the same verdicts mechanically after your write, so a
334
+ missed one self-corrects.
274
335
  Write the scope's section back with `PATCH <store= path> section=lessons
275
336
  mode=replace`, applying the Step-2 section-body-rebuild discipline (GET fresh,
276
337
  write the keep-list down first, byte-for-byte for unchanged bullets). Repeat
@@ -50,6 +50,27 @@ terminate.
50
50
 
51
51
  {integration_partial}
52
52
 
53
+ ### Turn efficiency
54
+
55
+ This sub-session runs under a hard `max_turns` cap — every model turn is one
56
+ round-trip, and a run that wanders past the cap is killed mid-fetch, so its
57
+ window is retried from scratch. Collapse the work into as few turns as you can:
58
+
59
+ - **Load tool schemas in ONE `ToolSearch` call.** On a Claude backend the
60
+ connector tools this integration uses are deferred, so their schemas must be
61
+ loaded before the first call. Load every schema you need in a single
62
+ `ToolSearch` (its `select:` query accepts a comma-separated list); never spend
63
+ one `ToolSearch` turn per tool.
64
+ - **Issue independent fetches together in one turn.** When `<acquisition-plan>`
65
+ carries several `<fetch>` rows (multiple windows or accounts), emit their
66
+ independent read calls in the SAME turn instead of one-per-turn — the rows do
67
+ not depend on each other, so serialising them only burns turns.
68
+ - **Never fetch per-item detail.** The search/list response already carries the
69
+ compact subset you submit (see the partial's `raw` shape). Do NOT make a
70
+ follow-up per-item call (`get_thread`, `get_event`, a per-message body fetch,
71
+ …) for data the list response already returned — that is one wasted turn per
72
+ item. Submit straight from the list response.
73
+
53
74
  ### Step 2 — Emit a single JSON line and terminate
54
75
 
55
76
  After every row has been processed (success, duplicate, or recorded
@@ -291,7 +291,9 @@ declares (`policies/agent-lessons.md` for the global `agent` scope;
291
291
  - Replace its members with **one** higher-level bullet that captures the
292
292
  shared principle:
293
293
  `- [<today>] <generalized directive> <!-- ev=<sum of the cluster's ev, min 1> kind=<the cluster's strongest kind> src=<strongest src> conf=<high if any member was high, else medium> last=<today> -->`
294
- (summing `ev` keeps the merged lesson harder to evict — never re-derive it lower).
294
+ (summing `ev` keeps the merged lesson harder to evict — never re-derive it
295
+ lower; omit `cf=` on a merged bullet — the daemon stamps it
296
+ deterministically after your write).
295
297
  - Leave a lesson that belongs to no cluster untouched, byte-for-byte.
296
298
  - **Never collapse, merge, or promote a `<!-- provisional -->` lesson.** The
297
299
  worksheet block lists only active (promoted) lessons; the file also holds
@@ -41,6 +41,22 @@ Global rules (apply at every step):
41
41
  `daily/*.md` file from this session — Step 5 is delegated. The
42
42
  daemon's parent audit row gates on YOUR success + today.md health,
43
43
  so a Stage B failure does not stop the day from "opening".
44
+ - Turn economy: operate in as few turns as possible. Consolidate tool
45
+ calls, do not narrate routine actions, and never re-derive facts
46
+ already in context. The independent read-only GETs — Step 2a mail,
47
+ Step 2b notion, the Step 2c non-direct calendar observations read,
48
+ Step 3 `actor=user`, Step 4 inbox list — MUST be issued together in
49
+ **one turn** as parallel tool calls; only a GET that immediately
50
+ precedes a `mode=replace` PATCH (rebuild discipline) needs to stay
51
+ adjacent to its write.
52
+ - Injected blocks (`<yesterday>`, `<calendar_events_7d>`,
53
+ `<fetch_report>`, `<handoff_parsed>`, `<user>`, …) are already in
54
+ your prompt — never GET a file merely to read what is injected; GET
55
+ fresh only immediately before a rebuild-and-replace write.
56
+ - curl rules: always double-quote URLs containing `&` (an unquoted
57
+ `&` backgrounds the command mid-URL), and never pass
58
+ `-w`/`--write-out` (the shell hook rejects it) — plain `curl -s`
59
+ output is sufficient.
44
60
 
45
61
  ### Step 1 — Read handoff and derive day-type
46
62
 
@@ -467,7 +483,8 @@ Global rules (apply at every step):
467
483
 
468
484
  Skip this step on recurring days — the row already exists.
469
485
 
470
- a. **Pre-flight.** `GET /api/recurring-schedules?enabled=true`
486
+ a. **Pre-flight.** `GET
487
+ /api/recurring-schedules?enabled=true&includeClaimed=true`
471
488
  and scan for an item with `taskType === "dm_session"` AND
472
489
  `taskContext.sub_flow === "morning_briefing"`. If found, skip
473
490
  the rest of this step — duplicate insertion would cause
@@ -661,12 +678,14 @@ the morning routine.
661
678
  need a flag in metadata.
662
679
 
663
680
  If the PATCH returns `agent_actions.session_row_not_found`
664
- (404), the dispatcher has not pre-inserted your in-flight row —
665
- surface a one-line warning to `## Agent Log`
666
- (`- HH:MM [morning_routine] agent-self self-report 404no in-flight row`)
667
- and continue. Do NOT block the turn on telemetry, and do NOT
668
- fall back to writing `journal/agent.md` directly (the daemon
669
- owns that file in V2; a direct write would race).
681
+ (404) the dispatcher has not pre-inserted your in-flight row —
682
+ or any other 4xx, surface a one-line warning to `## Agent Log`
683
+ (`- HH:MM [morning_routine] agent-self self-report <status><code>`)
684
+ and continue. Telemetry is best-effort: do NOT block the turn on
685
+ it, do NOT spend turns debugging headers or environment
686
+ variables, and do NOT fall back to writing `journal/agent.md`
687
+ directly (the daemon owns that file in V2; a direct write would
688
+ race).
670
689
 
671
690
  <output_language>english_only — Policy A surface (agent journal,
672
691
  parsed log); `<output_language_policy>` carves this out
@@ -0,0 +1,50 @@
1
+ {context}
2
+
3
+ ## Task: Source Library Maintenance
4
+
5
+ You are the source librarian. Documents the user sends over chat (PDF, PPTX, DOCX, XLSX, ODT) are captured automatically into a durable library; most weeks a few of them sit `unfiled`. Your job: file them as cards under `knowledge/sources/`, keep the collection taxonomy healthy, and repair any library↔vault drift. The `sources` skill carries the API surface, the current taxonomy, and the filing conventions — follow it for every call shape.
6
+
7
+ The scheduler only fires this routine when its prefilter found work; the event data carries `unfiledCount`, `inconsistencyCount`, and `driftSignalCount` so you know which phases matter this run.
8
+
9
+ ### Phase 1: Triage unfiled sources
10
+
11
+ 1. `GET /api/sources?status=unfiled` and read `knowledge/sources/_index.md` for the current collections.
12
+ 2. For each unfiled source, decide from `originalFilename` + `caption` + provenance what it is. Fetch the bytes into the workdir only when the metadata is genuinely insufficient (PDFs are directly readable with the Read tool; for PPTX/DOCX use the `unzip -p` text peek from the skill).
13
+ 3. File it per the skill's taxonomy and conventions: write the card (PUT), bind it (`PATCH /api/sources/<id>` with `cardPath`), and add the `## Sources` cross-link in the matching `plans/projects/<slug>.md` when a project applies.
14
+ 4. Junk or duplicates (`receive_count` > 1 with an existing card): `PATCH {"status":"archived"}` instead of writing a card. Never DELETE.
15
+ 5. Update `knowledge/sources/_index.md` when collections were added or their scope shifted.
16
+
17
+ ### Phase 2: Taxonomy review
18
+
19
+ Look at the collection shapes, not just this week's arrivals:
20
+
21
+ - **Singletons**: a collection with one card that fits an existing broader collection → move the card (PUT new path, DELETE old, PATCH `cardPath`).
22
+ - **Overloaded**: a collection past ~15 cards with visible sub-themes → split it.
23
+ - Keep moves small this run (≤ ~10 card moves). For a larger restructuring, delegate instead of doing it inline: compose a self-contained brief (current tree, target tree, move list, "PATCH each moved source's cardPath, update _index") and POST it —
24
+
25
+ ```bash
26
+ curl -s -X POST http://localhost:8321/api/background-task \
27
+ -H "Content-Type: application/json" \
28
+ -d '{"title":"Reorganize knowledge/sources collections","brief":"<self-contained instructions>","tier":"medium","notificationPolicy":"if_significant","origin":"agent"}'
29
+ ```
30
+
31
+ ### Phase 3: Consistency repair
32
+
33
+ For inconsistencies the prefilter counted:
34
+
35
+ - A `filed` source whose card file is missing → rewrite the card from the ledger metadata (or `PATCH {"status":"unfiled"}` if you cannot reconstruct it meaningfully).
36
+ - A card whose `source_id` has no ledger row → the binary is gone (owner hard-delete); note it in the card body and remove the card next pass if the owner confirms, or leave the card as the surviving record — judgement call, prefer preserving information.
37
+ - Report anything irrecoverable via `POST /api/notify` (priority low, one message for the whole run — never one per item).
38
+
39
+ ### Phase 4: Learn
40
+
41
+ - If the shipped taxonomy/filing anchors in the `sources` skill have drifted from how you actually filed things this run, submit a skill-curation proposal against those anchors (`POST /api/skill-curation/proposals`) so next week's pass starts from the better rules.
42
+ - Friction worth remembering (a collection rule that misfires, a provenance that always needs bytes fetched) → record one `self_critique` signal per distinct lesson; the consolidation loop folds it into your per-agent lessons, which are injected automatically next run:
43
+
44
+ ```bash
45
+ curl -s -X POST http://localhost:8321/api/feedback \
46
+ -H "Content-Type: application/json" \
47
+ -d '{"source":"self_critique","valence":"negative","scope_type":"agent_slug","scope_ref":"source-librarian","summary":"<one-line lesson, e.g. WhatsApp PDFs never carry captions - always fetch bytes before filing>"}'
48
+ ```
49
+
50
+ Silent by default: no user notification unless Phase 3 found something irrecoverable or a delegated reorg was spawned (one short DM via `/api/notify`, priority low).
@@ -93,14 +93,18 @@ person at 9am than during the day."
93
93
 
94
94
  ## Sub-flow routing
95
95
 
96
- The specific dm_session task is selected by `{event_data[task]}`
97
- prefix matching. Find the matching sub-flow below and follow its
98
- content rules.
99
-
100
- - starts with `morning briefing` see `## Morning briefing` below
101
- - starts with `task delivery:` see `## Task delivery` below
102
- - starts with `profile_interview:` see `## Profile interview` below
103
- - starts with `confirm:` → see `## Confirmation follow-up` below
96
+ The specific dm_session sub-flow is selected by the **structural**
97
+ `sub_flow` field inside `<task_context>` a value the daemon sets and
98
+ the user never edits, so routing stays correct even after the task's
99
+ prompt/content is freely edited (e.g. through the `task` board facade).
100
+ Read `sub_flow` out of the JSON in the `<task_context>` block and match
101
+ it below. If `sub_flow` is absent (legacy rows predating the field),
102
+ fall back to `{event_data[task]}` prefix matching.
103
+
104
+ - `sub_flow` is `morning_briefing` (legacy fallback: task starts with `morning briefing`) → see `## Morning briefing` below
105
+ - `sub_flow` is `task_delivery` (legacy fallback: task starts with `task delivery:`) → see `## Task delivery` below
106
+ - `sub_flow` is `profile_interview` (legacy fallback: task starts with `profile_interview:`) → see `## Profile interview` below
107
+ - `sub_flow` is `confirm` (legacy fallback: task starts with `confirm:`) → see `## Confirmation follow-up` below
104
108
  - (future sub-flows added here)
105
109
 
106
110
  If no sub-flow matches:
@@ -122,7 +126,8 @@ user verbatim — defeating the skip.
122
126
 
123
127
  ## Task delivery
124
128
 
125
- Triggered by `{event_data[task]}` starting with `task delivery:`.
129
+ Triggered by `sub_flow` = `task_delivery` in `<task_context>` (legacy
130
+ fallback: `{event_data[task]}` starts with `task delivery:`).
126
131
 
127
132
  Your final assistant turn IS the DM that delivers a background task
128
133
  artifact. The daemon has already decided that the owner is active in
@@ -157,21 +162,27 @@ Delivery rules:
157
162
  2. Preserve factual fidelity. Do not invent findings, counts, URLs, or
158
163
  decisions not present in `report` / `draft`. Do not claim a file is
159
164
  attached unless it appears in `assets`.
160
- 3. Do not mention implementation details such as task IDs,
165
+ 3. If `draft` carries a `Note: N of M requirements not fully met: …` line,
166
+ the task completed WITH GAPS — that disclosure must survive into your
167
+ DM (verbatim or tightly rephrased, naming the unmet items). Never
168
+ present a gapped result as a clean one, no matter how compact the
169
+ message needs to be.
170
+ 4. Do not mention implementation details such as task IDs,
161
171
  `task.delivery`, `scheduled.dm`, artifacts, metadata, API routes,
162
172
  context blocks, or background runners.
163
- 4. Keep the message compact. For long reports, summarize the decision
173
+ 5. Keep the message compact. For long reports, summarize the decision
164
174
  points and offer to pull details if the owner asks. If the owner later
165
175
  asks for a file again, you can re-send it from the task detail in a
166
176
  normal turn (the artifact API exposes the asset list).
167
- 5. End with exactly the message to send. Do not perform follow-up work in
177
+ 6. End with exactly the message to send. Do not perform follow-up work in
168
178
  this turn.
169
179
 
170
180
  ---
171
181
 
172
182
  ## Morning briefing
173
183
 
174
- Triggered by `{event_data[task]}` starting with `morning briefing`.
184
+ Triggered by `sub_flow` = `morning_briefing` in `<task_context>` (legacy
185
+ fallback: `{event_data[task]}` starts with `morning briefing`).
175
186
 
176
187
  > Universal rules from the notify skill § Universal user-facing
177
188
  > message discipline apply on top of the contract below — particularly
@@ -417,8 +428,9 @@ inside the closer line.
417
428
 
418
429
  ## Profile interview
419
430
 
420
- Triggered by `{event_data[task]}` starting with `profile_interview:<id>
421
- <ask-hint>`. This is the **fallback** path the morning routine
431
+ Triggered by `sub_flow` = `profile_interview` in `<task_context>` (legacy
432
+ routing fallback: `{event_data[task]}` starts with `profile_interview:<id>
433
+ — <ask-hint>`). This is the **fallback** path — the morning routine
422
434
  normally just lays the row latent and waits for an opportunity in DM /
423
435
  briefing. The evening sweep promotes a row to a scheduled DM only after
424
436
  3 days of no opportunity AND the user has been actively DMing.
@@ -483,7 +495,8 @@ row open.
483
495
 
484
496
  ## Confirmation follow-up
485
497
 
486
- Triggered by `{event_data[task]}` starting with `confirm:`. The DM
498
+ Triggered by `sub_flow` = `confirm` in `<task_context>` (legacy fallback:
499
+ `{event_data[task]}` starts with `confirm:`). The DM
487
500
  handler scheduled this row because a gate (e.g. project-creation, a
488
501
  managed-task duplicate, a long-horizon ambiguity) was triggered during
489
502
  an earlier DM but could not be asked then — either the conversation
@@ -13,6 +13,7 @@
13
13
  "identity/work.md": { "version": 2 },
14
14
  "journal/agent.md": { "version": 1 },
15
15
  "knowledge/dossiers/_index.md": { "version": 1 },
16
+ "knowledge/sources/_index.md": { "version": 1 },
16
17
  "knowledge/dossiers/evening.md": { "version": 1 },
17
18
  "knowledge/dossiers/activity-scan.md": { "version": 1 },
18
19
  "knowledge/dossiers/monthly.md": { "version": 1 },
@@ -0,0 +1,19 @@
1
+ ---
2
+ type: index
3
+ owner: agent
4
+ updated: 2026-07-01
5
+ template_version: 1
6
+ ---
7
+ # Sources
8
+
9
+ Directory of source-document collections (SOURCE_LIBRARY_DESIGN.md).
10
+ Each collection groups markdown cards describing documents the user
11
+ sent over chat; the binaries themselves live in the daemon's source
12
+ library and are referenced by each card's `source_id` frontmatter.
13
+
14
+ Maintained by the `sources` skill and the weekly source-librarian pass.
15
+ One line per collection with its one-phrase scope.
16
+
17
+ ## Collections
18
+
19
+ - (none yet — created as documents are filed)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aitne-sh/aitne",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Aitne — a local-first, proactive personal AI agent. A long-running TypeScript daemon is the nervous system; Claude Code (or Codex / Gemini CLI) is the brain. All persistent memory lives in local Markdown files.",
5
5
  "keywords": [
6
6
  "ai",
@@ -43,9 +43,9 @@
43
43
  "README.md"
44
44
  ],
45
45
  "dependencies": {
46
- "@aitne/daemon": "0.1.11",
47
- "@aitne/dashboard": "0.1.11",
48
- "@aitne/shared": "0.1.11"
46
+ "@aitne/daemon": "0.1.13",
47
+ "@aitne/dashboard": "0.1.13",
48
+ "@aitne/shared": "0.1.13"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@typescript-eslint/eslint-plugin": "^8.58.1",