@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.
- package/LICENSE +21 -0
- package/README.md +464 -0
- package/agent-assets/agent-profiles/_safety.md +26 -0
- package/agent-assets/agent-profiles/conversational.md +33 -0
- package/agent-assets/agent-profiles/docs-qa.md +24 -0
- package/agent-assets/agent-profiles/observer.md +28 -0
- package/agent-assets/agent-profiles/profile-importer.md +63 -0
- package/agent-assets/agent-profiles/proxy.md +28 -0
- package/agent-assets/agent-profiles/routine.md +16 -0
- package/agent-assets/agent-profiles/task.md +18 -0
- package/agent-assets/docs/concepts/agent-day.md +88 -0
- package/agent-assets/docs/concepts/auth-health.md +75 -0
- package/agent-assets/docs/concepts/backends-and-tiers.md +126 -0
- package/agent-assets/docs/concepts/costs-and-quotas.md +103 -0
- package/agent-assets/docs/concepts/delegated-mode.md +223 -0
- package/agent-assets/docs/concepts/memory-model.md +118 -0
- package/agent-assets/docs/concepts/observations.md +80 -0
- package/agent-assets/docs/concepts/process-keys.md +89 -0
- package/agent-assets/docs/concepts/routines.md +108 -0
- package/agent-assets/docs/concepts/safety-and-execution.md +109 -0
- package/agent-assets/docs/concepts/safety-model.md +279 -0
- package/agent-assets/docs/concepts/skills.md +100 -0
- package/agent-assets/docs/features/integrations/calendar.md +92 -0
- package/agent-assets/docs/features/integrations/git.md +95 -0
- package/agent-assets/docs/features/integrations/github.md +170 -0
- package/agent-assets/docs/features/integrations/mail.md +106 -0
- package/agent-assets/docs/features/integrations/notion.md +69 -0
- package/agent-assets/docs/features/integrations/obsidian.md +71 -0
- package/agent-assets/docs/features/lifestyle/git.md +178 -0
- package/agent-assets/docs/features/lifestyle/reading.md +93 -0
- package/agent-assets/docs/features/lifestyle/receipts.md +71 -0
- package/agent-assets/docs/features/lifestyle/travel-bookings.md +44 -0
- package/agent-assets/docs/features/lifestyle/travel-time.md +52 -0
- package/agent-assets/docs/features/memory-files/agent-journal.md +105 -0
- package/agent-assets/docs/features/memory-files/projects.md +56 -0
- package/agent-assets/docs/features/memory-files/roadmap.md +61 -0
- package/agent-assets/docs/features/memory-files/schedule.md +112 -0
- package/agent-assets/docs/features/memory-files/today.md +73 -0
- package/agent-assets/docs/features/memory-files/user-profile.md +81 -0
- package/agent-assets/docs/features/messaging/dashboard-chat.md +93 -0
- package/agent-assets/docs/features/messaging/discord.md +50 -0
- package/agent-assets/docs/features/messaging/overview.md +111 -0
- package/agent-assets/docs/features/messaging/pairing-and-magic-phrase.md +69 -0
- package/agent-assets/docs/features/messaging/slack.md +51 -0
- package/agent-assets/docs/features/messaging/telegram.md +63 -0
- package/agent-assets/docs/features/messaging/whatsapp.md +48 -0
- package/agent-assets/docs/features/operations/activity-and-conversations.md +105 -0
- package/agent-assets/docs/features/operations/approvals.md +58 -0
- package/agent-assets/docs/features/operations/backend-routing.md +62 -0
- package/agent-assets/docs/features/operations/cost-tracking.md +59 -0
- package/agent-assets/docs/features/operations/notifications.md +69 -0
- package/agent-assets/docs/features/operations/quiet-hours.md +106 -0
- package/agent-assets/docs/features/operations/schedule-approaching.md +60 -0
- package/agent-assets/docs/features/routines/custom-routines.md +101 -0
- package/agent-assets/docs/features/routines/evening-review.md +81 -0
- package/agent-assets/docs/features/routines/hourly-check.md +85 -0
- package/agent-assets/docs/features/routines/monthly-review.md +65 -0
- package/agent-assets/docs/features/routines/morning-routine.md +123 -0
- package/agent-assets/docs/features/routines/weekly-review.md +70 -0
- package/agent-assets/docs/getting-started/01-what-is-this.md +192 -0
- package/agent-assets/docs/getting-started/02-first-steps.md +80 -0
- package/agent-assets/docs/getting-started/03-what-can-this-do.md +110 -0
- package/agent-assets/docs/getting-started/04-first-day.md +287 -0
- package/agent-assets/docs/glossary.md +116 -0
- package/agent-assets/docs/guides/add-a-custom-routine.md +71 -0
- package/agent-assets/docs/guides/backup-and-restore.md +54 -0
- package/agent-assets/docs/guides/change-which-model-handles-x.md +47 -0
- package/agent-assets/docs/guides/connect-a-new-mail-account.md +59 -0
- package/agent-assets/docs/guides/import-knowledge-file.md +275 -0
- package/agent-assets/docs/guides/install-and-run.md +72 -0
- package/agent-assets/docs/guides/migrate-machines.md +52 -0
- package/agent-assets/docs/guides/pause-the-agent.md +65 -0
- package/agent-assets/docs/guides/reinstall-cleanly.md +52 -0
- package/agent-assets/docs/guides/setup-wizard.md +107 -0
- package/agent-assets/docs/guides/switch-default-backend.md +60 -0
- package/agent-assets/docs/reference/api.md +51 -0
- package/agent-assets/docs/reference/cli-commands.md +121 -0
- package/agent-assets/docs/reference/config.md +74 -0
- package/agent-assets/docs/reference/disallowed-tools.md +76 -0
- package/agent-assets/docs/reference/keyboard-shortcuts.md +39 -0
- package/agent-assets/docs/reference/process-keys.md +59 -0
- package/agent-assets/docs/reference/skills.md +50 -0
- package/agent-assets/docs/troubleshooting/auth-failed.md +57 -0
- package/agent-assets/docs/troubleshooting/dashboard-shows-degraded.md +55 -0
- package/agent-assets/docs/troubleshooting/fallback-keeps-firing.md +54 -0
- package/agent-assets/docs/troubleshooting/messaging-not-pairing.md +53 -0
- package/agent-assets/docs/troubleshooting/morning-routine-didnt-run.md +75 -0
- package/agent-assets/docs/troubleshooting/observation-not-detected.md +57 -0
- package/agent-assets/docs/troubleshooting/quota-exhausted.md +57 -0
- package/agent-assets/optimizer-skills/drift-analysis/SKILL.md +75 -0
- package/agent-assets/optimizer-skills/knowledge-map/SKILL.md +71 -0
- package/agent-assets/optimizer-skills/skill-curation/SKILL.md +108 -0
- package/agent-assets/project-doc-templates/git-repo.md +21 -0
- package/agent-assets/project-doc-templates/project.md +38 -0
- package/agent-assets/skills/attach/SKILL.md +104 -0
- package/agent-assets/skills/context/SKILL.md +257 -0
- package/agent-assets/skills/context/curation.json +37 -0
- package/agent-assets/skills/context/seeds/file-responsibilities.seed.json +13 -0
- package/agent-assets/skills/context/seeds/frontmatter-requirements.seed.json +40 -0
- package/agent-assets/skills/docs-search/SKILL.md +176 -0
- package/agent-assets/skills/external-services/SKILL.delegated.claude.md +369 -0
- package/agent-assets/skills/external-services/SKILL.delegated.codex.md +349 -0
- package/agent-assets/skills/external-services/SKILL.delegated.gemini.md +347 -0
- package/agent-assets/skills/external-services/SKILL.md +371 -0
- package/agent-assets/skills/mail/SKILL.delegated.claude.md +284 -0
- package/agent-assets/skills/mail/SKILL.delegated.codex.md +261 -0
- package/agent-assets/skills/mail/SKILL.delegated.gemini.md +255 -0
- package/agent-assets/skills/mail/SKILL.md +313 -0
- package/agent-assets/skills/mail/references/errors.md +17 -0
- package/agent-assets/skills/mail/references/providers.md +40 -0
- package/agent-assets/skills/mail/references/query-grammar.md +24 -0
- package/agent-assets/skills/management-policy/SKILL.md +307 -0
- package/agent-assets/skills/management-policy/curation.json +13 -0
- package/agent-assets/skills/management-policy/seeds/policy-file-shape.seed.json +16 -0
- package/agent-assets/skills/management-task-modify/SKILL.md +202 -0
- package/agent-assets/skills/management-task-register/SKILL.md +330 -0
- package/agent-assets/skills/management-task-stop/SKILL.md +166 -0
- package/agent-assets/skills/notify/SKILL.md +196 -0
- package/agent-assets/skills/notion/SKILL.delegated.claude.md +254 -0
- package/agent-assets/skills/notion/SKILL.delegated.codex.md +195 -0
- package/agent-assets/skills/notion/SKILL.delegated.gemini.md +194 -0
- package/agent-assets/skills/notion/SKILL.md +86 -0
- package/agent-assets/skills/observations/SKILL.md +234 -0
- package/agent-assets/skills/observations/curation.json +13 -0
- package/agent-assets/skills/observations/seeds/source-namespacing.seed.json +20 -0
- package/agent-assets/skills/project-doc/SKILL.md +86 -0
- package/agent-assets/skills/project-doc/curation.json +21 -0
- package/agent-assets/skills/project-doc/seeds/project-shape.seed.json +25 -0
- package/agent-assets/skills/project-doc/seeds/slug-grammar.seed.json +20 -0
- package/agent-assets/skills/reading/SKILL.md +198 -0
- package/agent-assets/skills/reading/references/reading-taste.md +197 -0
- package/agent-assets/skills/receipts/SKILL.md +134 -0
- package/agent-assets/skills/roadmap/SKILL.md +276 -0
- package/agent-assets/skills/roadmap/curation.json +13 -0
- package/agent-assets/skills/roadmap/references/horizon-tags.md +40 -0
- package/agent-assets/skills/roadmap/references/preparation-timeline.md +47 -0
- package/agent-assets/skills/roadmap/seeds/entry-types.seed.json +16 -0
- package/agent-assets/skills/schedule/SKILL.md +228 -0
- package/agent-assets/skills/scheduled-managed-task/SKILL.md +392 -0
- package/agent-assets/skills/today/SKILL.md +198 -0
- package/agent-assets/skills/today/curation.json +21 -0
- package/agent-assets/skills/today/seeds/agent-notes-flavors.seed.json +17 -0
- package/agent-assets/skills/today/seeds/section-shape.seed.json +17 -0
- package/agent-assets/skills/travel/SKILL.md +132 -0
- package/agent-assets/skills/travel-time/SKILL.md +149 -0
- package/agent-assets/skills/user-interview/SKILL.md +323 -0
- package/agent-assets/skills/user-interview/references/sweep-and-fallback.md +94 -0
- package/agent-assets/skills/user-profile/SKILL.md +210 -0
- package/agent-assets/skills/user-profile/curation.json +29 -0
- package/agent-assets/skills/user-profile/seeds/learned-context-format.seed.json +14 -0
- package/agent-assets/skills/user-profile/seeds/routing-table.seed.json +53 -0
- package/agent-assets/skills/user-profile/seeds/topic-files.seed.json +27 -0
- package/agent-assets/task-flows/dashboard.docs_qa.md +43 -0
- package/agent-assets/task-flows/default.md +11 -0
- package/agent-assets/task-flows/git.branch.created.md +25 -0
- package/agent-assets/task-flows/git.lifecycle.poll.md +52 -0
- package/agent-assets/task-flows/git.local_ahead.stale.md +34 -0
- package/agent-assets/task-flows/git.merge_to_default.md +30 -0
- package/agent-assets/task-flows/git.project.refresh_architecture.md +100 -0
- package/agent-assets/task-flows/git.project.retemplate.md +73 -0
- package/agent-assets/task-flows/git.push.detected.md +32 -0
- package/agent-assets/task-flows/git.push.force_pushed.md +36 -0
- package/agent-assets/task-flows/git.tag.created.md +24 -0
- package/agent-assets/task-flows/github.assigned.md +43 -0
- package/agent-assets/task-flows/github.pull_request.review_requested.md +57 -0
- package/agent-assets/task-flows/github.security_alert.md +45 -0
- package/agent-assets/task-flows/github.workflow_run.failed.md +57 -0
- package/agent-assets/task-flows/knowledge.import.md +161 -0
- package/agent-assets/task-flows/message.received.dm.md +142 -0
- package/agent-assets/task-flows/message.received.dm_first.md +117 -0
- package/agent-assets/task-flows/message.received.md +14 -0
- package/agent-assets/task-flows/routine.custom.md +38 -0
- package/agent-assets/task-flows/routine.evening_review.md +323 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.claude.md +405 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.codex.md +400 -0
- package/agent-assets/task-flows/routine.hourly_check.delegated.gemini.md +404 -0
- package/agent-assets/task-flows/routine.hourly_check.md +184 -0
- package/agent-assets/task-flows/routine.hourly_check.triage.md +93 -0
- package/agent-assets/task-flows/routine.monthly_review.md +250 -0
- package/agent-assets/task-flows/routine.morning_routine.md +300 -0
- package/agent-assets/task-flows/routine.morning_routine_initial.md +184 -0
- package/agent-assets/task-flows/routine.roadmap_refresh.md +275 -0
- package/agent-assets/task-flows/routine.today_refresh.md +172 -0
- package/agent-assets/task-flows/routine.user_profile_sweep.md +242 -0
- package/agent-assets/task-flows/routine.weekly_review.md +247 -0
- package/agent-assets/task-flows/schedule.approaching.md +124 -0
- package/agent-assets/task-flows/scheduled.dm.md +391 -0
- package/agent-assets/task-flows/scheduled.task.md +141 -0
- package/agent-assets/task-flows/setup.initial.md +277 -0
- package/agent-assets/task-flows/setup.update.md +53 -0
- package/agent-assets/templates/README.md +85 -0
- package/agent-assets/templates/_index.md +39 -0
- package/agent-assets/templates/_manifest.json +103 -0
- package/agent-assets/templates/agent/journal.md +10 -0
- package/agent-assets/templates/agent/profile-questions.md +74 -0
- package/agent-assets/templates/context-index.md +42 -0
- package/agent-assets/templates/dossiers/_index.md +22 -0
- package/agent-assets/templates/dossiers/evening.md +23 -0
- package/agent-assets/templates/dossiers/hourly.md +23 -0
- package/agent-assets/templates/dossiers/monthly.md +23 -0
- package/agent-assets/templates/dossiers/morning.md +23 -0
- package/agent-assets/templates/dossiers/roadmap.md +23 -0
- package/agent-assets/templates/dossiers/weekly.md +23 -0
- package/agent-assets/templates/projects/_active.base +14 -0
- package/agent-assets/templates/projects/_index.md +29 -0
- package/agent-assets/templates/roadmap.md +15 -0
- package/agent-assets/templates/routines/_index.md +20 -0
- package/agent-assets/templates/routines/evening.md +22 -0
- package/agent-assets/templates/routines/hourly.md +30 -0
- package/agent-assets/templates/routines/monthly.md +25 -0
- package/agent-assets/templates/routines/morning.md +26 -0
- package/agent-assets/templates/routines/weekly.md +23 -0
- package/agent-assets/templates/rules/_index.md +19 -0
- package/agent-assets/templates/rules/journal-export.md +41 -0
- package/agent-assets/templates/rules/journal-format.md +61 -0
- package/agent-assets/templates/rules/management.md +48 -0
- package/agent-assets/templates/rules/mcp.md +40 -0
- package/agent-assets/templates/rules/policies/_index.md +22 -0
- package/agent-assets/templates/rules/redaction.md +30 -0
- package/agent-assets/templates/today.md +13 -0
- package/agent-assets/templates/user/_index.md +16 -0
- package/agent-assets/templates/user/expertise.md +7 -0
- package/agent-assets/templates/user/goals.md +7 -0
- package/agent-assets/templates/user/people.md +7 -0
- package/agent-assets/templates/user/personal.md +7 -0
- package/agent-assets/templates/user/profile.md +28 -0
- package/agent-assets/templates/user/work.md +7 -0
- package/bin/aitne.mjs +1096 -0
- package/package.json +78 -0
- package/personal-agent.mjs +39 -0
- package/scripts/browser.mjs +99 -0
- package/scripts/check-redaction-coverage.mjs +109 -0
- package/scripts/commands/audit.mjs +309 -0
- package/scripts/commands/doctor.mjs +437 -0
- package/scripts/commands/open.mjs +40 -0
- package/scripts/commands/setup.mjs +21 -0
- package/scripts/commands/uninstall.mjs +114 -0
- package/scripts/commands/update.mjs +96 -0
- package/scripts/commands/version.mjs +62 -0
- package/scripts/commands.md +0 -0
- package/scripts/lib/sqlite-loader.mjs +49 -0
- package/scripts/message-discipline-digest.mjs +535 -0
- package/scripts/poc/google-connector-inheritance/REPORT.md +197 -0
- package/scripts/poc/google-connector-inheritance/claude-sdk-probe.mjs +79 -0
- package/scripts/remint-roadmap-ids.mjs +257 -0
- package/scripts/rm-paths.mjs +22 -0
- package/scripts/run-node.mjs +223 -0
- package/scripts/smoke-obsidian-api.mjs +166 -0
- package/scripts/start.mjs +160 -0
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scheduled-managed-task
|
|
3
|
+
description: Run an `mt_<n>` managed task at its scheduled slot — pick a tool, fetch since last run, resolve to entity via §7.6, merge into `<domain>/<type-plural>/<slug>.md`. Trigger when `task_context.mt_id` matches `mt_<n>`; `task_context.adhoc === true` means run-now.
|
|
4
|
+
when_to_use: A `scheduled.task` session with `task_context.mt_id` matching `mt_<n>`; `task_context.adhoc === true` marks on-demand pulls. SKIP for regular scheduled tasks, DM-tone scheduled sessions (`scheduled.dm`), or one-off reminder delivery.
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash(curl *)
|
|
7
|
+
- Bash(jq *)
|
|
8
|
+
- Read
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Scheduled Managed-Task Run
|
|
12
|
+
|
|
13
|
+
This skill is the **scheduled execution** half of the management
|
|
14
|
+
registry. The DM-side counterparts —
|
|
15
|
+
`management-task-register` / `-modify` / `-stop` — own the row's
|
|
16
|
+
lifecycle. This skill is what fires every cron slot to actually do
|
|
17
|
+
the work.
|
|
18
|
+
|
|
19
|
+
## When this skill activates
|
|
20
|
+
|
|
21
|
+
Auto-loaded when the dispatcher routes a `scheduled.task` event whose
|
|
22
|
+
`task_context.mt_id` matches `^mt_[1-9]\d*$`. The `mt_id` field in
|
|
23
|
+
`task_context` is the contract between the managed-tasks route and
|
|
24
|
+
this skill — both the recurring fire (`POST /api/managed-tasks` →
|
|
25
|
+
`recurring_schedules` → `agent_schedule`) and the on-demand fire
|
|
26
|
+
(`POST /api/managed-tasks/:id/run-now`) populate it. The
|
|
27
|
+
`task_context.adhoc === true` boolean (also set by the on-demand
|
|
28
|
+
route) signals which one you're in.
|
|
29
|
+
|
|
30
|
+
If `task_context.mt_id` is absent, this is **not** a managed-task
|
|
31
|
+
run — fall through to the regular `scheduled.task` flow per
|
|
32
|
+
`scheduled.task.md`.
|
|
33
|
+
|
|
34
|
+
## Algorithm (mirror of design 21 §10.4)
|
|
35
|
+
|
|
36
|
+
### Step 0 — Identify the row
|
|
37
|
+
|
|
38
|
+
Pull `mt_<n>` from `task_context.mt_id`. When `task_context.adhoc ===
|
|
39
|
+
true`, this run came from `POST /api/managed-tasks/:id/run-now` — the
|
|
40
|
+
row's `last_run_at` IS updated, but the audit row gets tagged
|
|
41
|
+
`adhoc:true` so the activity-view reconciler can distinguish it. The
|
|
42
|
+
`task_context.reason` field (from the run-now body) is a free-text
|
|
43
|
+
hint about why the user pulled.
|
|
44
|
+
|
|
45
|
+
### Step 1 — Read the row
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
curl -s "http://localhost:8321/api/managed-tasks/mt_43" | jq .item
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The route wraps the row in `{item:<ManagedTask>}`. Relevant fields on
|
|
52
|
+
`item`:
|
|
53
|
+
|
|
54
|
+
```jsonc
|
|
55
|
+
{
|
|
56
|
+
"id": "mt_43",
|
|
57
|
+
"intent": "Zoom recordings → meeting entity",
|
|
58
|
+
"app": "zoom",
|
|
59
|
+
"app_normalized": "zoom",
|
|
60
|
+
"cadence": "daily 10:00 (Asia/Tokyo)",
|
|
61
|
+
"output_path": "work/meetings/", // may be null on first run
|
|
62
|
+
"schedule_id": 17,
|
|
63
|
+
"last_run_at": "2026-12-04T10:00:00Z",
|
|
64
|
+
"last_result": "ok (3 new)",
|
|
65
|
+
"consecutive_failures": 0
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
If the GET returns 404, the row was stopped between schedule firing
|
|
70
|
+
and skill invocation. End the session quietly — the daemon's audit
|
|
71
|
+
records the orphan firing.
|
|
72
|
+
|
|
73
|
+
### Step 2 — Select tool (LLM judgment, fresh each run)
|
|
74
|
+
|
|
75
|
+
Same rule as `management-task-register` Step 3: enumerate the
|
|
76
|
+
tools available to this session and pick by capability for
|
|
77
|
+
`item.app`. The user's prior choice (when surfaced as a hint in
|
|
78
|
+
`task_context.lastToolChoice` by an earlier run) is a **hint**, not
|
|
79
|
+
a binding — if it no longer exists in this session (the user
|
|
80
|
+
reinstalled MCPs, the backend rotated), pick afresh.
|
|
81
|
+
|
|
82
|
+
- **Zero plausible** → record `last_result='failed: connector
|
|
83
|
+
unavailable'`; the three-strikes rule (§10.4 step 6) handles
|
|
84
|
+
user-facing notification. Stop.
|
|
85
|
+
- **Multiple plausible AND no hint** → record `last_result='failed:
|
|
86
|
+
ambiguous tool selection'`; the next on-demand DM lets the user
|
|
87
|
+
disambiguate. Stop.
|
|
88
|
+
- **One plausible OR hint resolves** → continue.
|
|
89
|
+
|
|
90
|
+
NEVER hardcode tool names — see ADR §8.4 / FR-4.
|
|
91
|
+
|
|
92
|
+
### Step 3 — Invoke with `since = last_run_at`
|
|
93
|
+
|
|
94
|
+
Issue the smallest read that returns "everything new since
|
|
95
|
+
`last_run_at`". For most apps that is a `since` / `updated_after` /
|
|
96
|
+
`q: "after:<ISO>"` parameter. If the tool only exposes a `limit`,
|
|
97
|
+
fetch a generous page and filter client-side.
|
|
98
|
+
|
|
99
|
+
For an `.adhoc` run with no explicit `since` from the user, default
|
|
100
|
+
to `now − 24h` (safety: don't pull months on a manual fire).
|
|
101
|
+
|
|
102
|
+
If the tool returns an error, record `last_result='failed: <verbatim
|
|
103
|
+
error>'` and stop. The 3-strikes rule (Step 6) governs notifications.
|
|
104
|
+
|
|
105
|
+
### Step 4 — Resolve each new datum to an entity (§7.6 lookup contract)
|
|
106
|
+
|
|
107
|
+
For every new item the tool returned, decide *which* `<domain>/<type-plural>/<slug>.md`
|
|
108
|
+
file to merge it into. Lookup precedence is **strict** — fall through
|
|
109
|
+
in order:
|
|
110
|
+
|
|
111
|
+
#### 4.1 Exact `(source_key, external_id)` match
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
curl -s "http://localhost:8321/api/entities?source=zoom&external_id=zm_xyz789" | jq .
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
If 1 result, that's the entity. Reuse its `path`. This is the
|
|
118
|
+
strongest signal and guarantees no duplicates when the upstream app
|
|
119
|
+
exposes a stable id.
|
|
120
|
+
|
|
121
|
+
If >1 result the mirror is corrupted — record
|
|
122
|
+
`last_result='failed: entity-mirror conflict'` and stop. The boot
|
|
123
|
+
reconciler converges from the L2 files.
|
|
124
|
+
|
|
125
|
+
#### 4.2 Fallback: `(domain, type, date, fuzzy title)` within ±48 h
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
curl -s "http://localhost:8321/api/entities?domain=work&type=meeting&date=2026-12-04&q=foo+1on1" | jq .
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The daemon does the fuzzy match server-side (token-overlap on
|
|
132
|
+
`title`). If 1 confident result, reuse. If >1 confident result, pick
|
|
133
|
+
the one whose `sources.<other_app>.*` already overlaps with this
|
|
134
|
+
datum's metadata (e.g. a Calendar entity already bound to the same
|
|
135
|
+
attendees → that's the right meeting).
|
|
136
|
+
|
|
137
|
+
#### 4.3 Otherwise: allocate a new entity
|
|
138
|
+
|
|
139
|
+
Decide `(domain, type)` from the datum shape. **Bias toward the row's
|
|
140
|
+
`output_path`** when present — it encodes the user's intent for this
|
|
141
|
+
managed task:
|
|
142
|
+
|
|
143
|
+
```
|
|
144
|
+
output_path = "work/meetings/" → domain=work, type=meeting
|
|
145
|
+
output_path = "finance/receipts/" → domain=finance, type=receipt
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
If `output_path` is null (first run), pick the best `(domain, type)`
|
|
149
|
+
from the data shape using the same prior table from
|
|
150
|
+
`management-task-register` Step 4a. After this run, write the
|
|
151
|
+
chosen path back to the row (Step 5b) so subsequent runs converge.
|
|
152
|
+
|
|
153
|
+
Slug: `<YYYY-MM-DD>-<sanitized-title>`. Sanitization rules:
|
|
154
|
+
lowercase, ASCII-fold, replace `[^a-z0-9-]+` with `-`, collapse
|
|
155
|
+
runs of `-`, trim leading/trailing `-`, cap at 64 chars. The slug
|
|
156
|
+
must match `^[a-z0-9][a-z0-9-]*$` per §9.3 EntitySchema.
|
|
157
|
+
|
|
158
|
+
### Step 5a — Merge into the entity file
|
|
159
|
+
|
|
160
|
+
For each resolved entity:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
curl -sS -X PATCH "http://localhost:8321/api/context/work/meetings/2026-12-04-foo-1on1" \
|
|
164
|
+
-H 'Content-Type: application/json' \
|
|
165
|
+
-d @- <<'JSON'
|
|
166
|
+
{
|
|
167
|
+
"section": "Zoom Notes",
|
|
168
|
+
"mode": "append",
|
|
169
|
+
"content": "- duration 60 min\n- recording: <link>\n- external_id: zm_xyz789\n- transcript snippet: …\n"
|
|
170
|
+
}
|
|
171
|
+
JSON
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The daemon's section-append `mode:"append"` adds the lines under the
|
|
175
|
+
named `## Zoom Notes` heading; the heading itself is stable across
|
|
176
|
+
runs. The (`section`, `mode`, `content`, `cutoff`, `maxEntries`)
|
|
177
|
+
shape is the contract today — see `contextPatchSchema` in
|
|
178
|
+
`packages/shared/src/schemas.ts`.
|
|
179
|
+
|
|
180
|
+
**Source-id capture (write the `external_id` into the body lines):**
|
|
181
|
+
the entity-mirror watcher (P5) reparses the file's frontmatter on
|
|
182
|
+
change, so the dedup contract in §7.6 hinges on the upstream id
|
|
183
|
+
landing in **frontmatter**, not just the body. Until the entity-mirror
|
|
184
|
+
reconciler ships AND the context API gains a `frontmatter*` patch
|
|
185
|
+
mode for `<domain>/<type-plural>/*` files, do this:
|
|
186
|
+
|
|
187
|
+
1. Always include `- external_id: <id>` on its own line in the
|
|
188
|
+
appended `## <App> Notes` body so a future reconciler-rebuild can
|
|
189
|
+
recover the binding from prose.
|
|
190
|
+
2. Track the binding in the §B "Recently changed" path — the
|
|
191
|
+
`agent_actions.management_task.run_recorded` row's `detail` is
|
|
192
|
+
structured and survives even when the file body doesn't reflect
|
|
193
|
+
the binding cleanly.
|
|
194
|
+
|
|
195
|
+
> **Implementation gap to flag** (Phase 5 / extended Phase 3): the
|
|
196
|
+
> context PATCH route does not currently:
|
|
197
|
+
> - allow writes under `<domain>/<type-plural>/*` (no entry in
|
|
198
|
+
> `CONTEXT_WRITE_PERMISSIONS`), so this PATCH returns `403
|
|
199
|
+
> forbidden` until the whitelist is widened, and
|
|
200
|
+
> - expose a `frontmatterMerge` mode for deep-merging
|
|
201
|
+
> `frontmatter.sources.<app>`.
|
|
202
|
+
> Both are required by design 21 §10.4 step 4b and must land before
|
|
203
|
+
> this Step 5a goes from "designed" to "operational". Until then,
|
|
204
|
+
> Step 5b's audit row is the durable trace of the run — surface that
|
|
205
|
+
> in the activity-view rather than relying on the entity body.
|
|
206
|
+
|
|
207
|
+
If the entity file does not previously exist, today's API requires a
|
|
208
|
+
PUT with full content (the `<domain>/<type-plural>/*` write path is
|
|
209
|
+
gated by the same whitelist note above). When the gap closes, the
|
|
210
|
+
first PATCH must include a complete frontmatter block — `type`,
|
|
211
|
+
`domain`, `slug`, `title`, `created`, `sources` — or the daemon
|
|
212
|
+
returns 422 against `EntitySchema`.
|
|
213
|
+
|
|
214
|
+
### Step 5b — Update the row
|
|
215
|
+
|
|
216
|
+
The user-facing PATCH (`/api/managed-tasks/:id`) is **immutable** for
|
|
217
|
+
`last_run_at` / `last_result` / `consecutive_failures` by design — those
|
|
218
|
+
fields are written by this skill through a dedicated internal endpoint
|
|
219
|
+
so the user-facing surface and the run-result surface have separate
|
|
220
|
+
schemas and risk-tier intents.
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Success path
|
|
224
|
+
curl -sS -X PATCH http://localhost:8321/api/managed-tasks/mt_43/run-result \
|
|
225
|
+
-H 'Content-Type: application/json' \
|
|
226
|
+
-d '{"last_run_at":"2026-12-04T10:00:00Z","last_result":"ok (3 new)","consecutive_failures":0}'
|
|
227
|
+
|
|
228
|
+
# Failure path — explicit count, NOT an increment flag
|
|
229
|
+
curl -sS -X PATCH http://localhost:8321/api/managed-tasks/mt_43/run-result \
|
|
230
|
+
-H 'Content-Type: application/json' \
|
|
231
|
+
-d '{"last_run_at":"2026-12-04T10:00:00Z","last_result":"failed: <reason>","consecutive_failures":<prev+1>}'
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
`managedTaskRunResultSchema` is **replace-semantics** for
|
|
235
|
+
`consecutive_failures` — read the previous value from Step 1's
|
|
236
|
+
response and send the next integer (`prev + 1` for failures, `0` for
|
|
237
|
+
success). There is no `consecutiveFailuresIncrement` flag.
|
|
238
|
+
|
|
239
|
+
**Output-path back-fill.** If `output_path` was null going in and you
|
|
240
|
+
allocated entities under one consistent `<domain>/<type-plural>/`,
|
|
241
|
+
relocate it via the user-facing PATCH **after** the run-result PATCH
|
|
242
|
+
(two writes — the schemas don't overlap):
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
curl -sS -X PATCH http://localhost:8321/api/managed-tasks/mt_43 \
|
|
246
|
+
-H 'Content-Type: application/json' \
|
|
247
|
+
-d '{"output_path":"work/meetings/"}'
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
The two-step write is intentional — the user-facing PATCH emits a
|
|
251
|
+
`management_task.modified` audit row with `from`/`to`, which is the
|
|
252
|
+
right signal for "the agent learned the path on its own". Combining
|
|
253
|
+
both into `/run-result` would hide the path change in a less specific
|
|
254
|
+
audit shape.
|
|
255
|
+
|
|
256
|
+
If the run produced a mix of domains/types (e.g. Drive PDFs that were
|
|
257
|
+
half receipts and half random docs), leave `output_path` null — let
|
|
258
|
+
the next run try again. The renderer marks null-path rows in §B with
|
|
259
|
+
an em-dash; the user can also set the path explicitly via
|
|
260
|
+
`management-task-modify`.
|
|
261
|
+
|
|
262
|
+
### Step 6 — Three-strikes notify
|
|
263
|
+
|
|
264
|
+
The design (§10.4 step 6) places the 3-strikes notify on the daemon
|
|
265
|
+
side: the `/run-result` route should auto-enqueue a `POST /api/notify`
|
|
266
|
+
when the post-update `consecutive_failures` crosses the threshold,
|
|
267
|
+
keeping the agent out of the user-paging loop and centralizing the
|
|
268
|
+
threshold (`managementFailureNotifyThreshold`, default 3).
|
|
269
|
+
|
|
270
|
+
**Implementation status:** the daemon does NOT currently emit this
|
|
271
|
+
notify — `/api/managed-tasks/:id/run-result` records the run and
|
|
272
|
+
re-renders the file but stops there. Until the daemon closes the
|
|
273
|
+
gap, **this skill is the safety net**: after Step 5b's failure-path
|
|
274
|
+
PATCH, if the post-update `consecutive_failures` you computed is ≥ 3
|
|
275
|
+
AND was < 3 before this run (i.e. the *crossing*, not every
|
|
276
|
+
subsequent failure), call:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
curl -sS -X POST http://localhost:8321/api/notify \
|
|
280
|
+
-H 'Content-Type: application/json' \
|
|
281
|
+
-d '{
|
|
282
|
+
"message": "Managed task mt_43 has failed 3 consecutive runs: <reason>. The schedule remains active. Stop or modify it via DM.",
|
|
283
|
+
"priority": "normal"
|
|
284
|
+
}'
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
The crossing-edge condition is critical — DM-ing on every failure
|
|
288
|
+
once over the threshold would spam the user. Trip on the transition
|
|
289
|
+
3-to-now-3, never on 4 → 4 / 5 → 5 / etc.
|
|
290
|
+
|
|
291
|
+
The schedule is **never auto-stopped** — see ADR-flavored note in
|
|
292
|
+
§10.4: "Auto-stop would silently lose user intent. Notify-then-defer-
|
|
293
|
+
to-user honors 'destructive ops require user confirmation'." So the
|
|
294
|
+
agent keeps trying, but doesn't disappear silently.
|
|
295
|
+
|
|
296
|
+
### Step 7 — End the session
|
|
297
|
+
|
|
298
|
+
`scheduled.task` flow's "Output contract — your final text becomes a
|
|
299
|
+
DM" applies (`scheduled.task.md`). For managed-task runs the default
|
|
300
|
+
is **empty final text**: bookkeeping is invisible by design. The user
|
|
301
|
+
sees the change reflected in `_activity/<source>.md` (auto-built) and
|
|
302
|
+
`<domain>/_index.md`, not in a chat ping per fire.
|
|
303
|
+
|
|
304
|
+
Exceptions:
|
|
305
|
+
|
|
306
|
+
- The `notify` skill's awareness gate fired *during* this run — e.g.
|
|
307
|
+
the new datum is a meeting starting in 15 min. Then call
|
|
308
|
+
`/api/notify` and keep the final text empty (a follow-up "Sent"
|
|
309
|
+
line is duplicate noise per `scheduled.task.md`).
|
|
310
|
+
- `last_result='failed: ...'` with `consecutive_failures < 3` — final
|
|
311
|
+
text empty; the activity view records it; the user is not paged.
|
|
312
|
+
- `last_result='failed: ...'` at the threshold crossing — Step 6 fired
|
|
313
|
+
the `/api/notify`; final text empty.
|
|
314
|
+
|
|
315
|
+
NEVER write a `## Agent Plan` row for a managed-task run — managed
|
|
316
|
+
tasks are not the same as Agent Plan rows. The Agent Plan loop close
|
|
317
|
+
in `scheduled.task.md` Step 4 is for DM-originated tasks, not for
|
|
318
|
+
`mt_<n>` correlated firings. Skip Steps 1 / 4 of `scheduled.task.md`
|
|
319
|
+
when this skill is the executing skill.
|
|
320
|
+
|
|
321
|
+
## Idempotency
|
|
322
|
+
|
|
323
|
+
A scheduled fire that crashes mid-run leaves the row's
|
|
324
|
+
`last_run_at` un-updated. The next slot picks up the same `since`
|
|
325
|
+
window and re-fetches the same data — the entity-mirror's
|
|
326
|
+
`(source_key, external_id)` lookup makes this a **merge**, not a
|
|
327
|
+
duplicate. The PATCH body is content-additive: a section appended
|
|
328
|
+
twice with the same content is harmless because Step 5a's
|
|
329
|
+
`frontmatterMerge` is deep, and the section-append mode is
|
|
330
|
+
"add this block as-is" (the daemon de-duplicates exact-string-match
|
|
331
|
+
sections with the same heading on append). For sources without a
|
|
332
|
+
stable `external_id`, use Step 4.2's date+title window — at the cost
|
|
333
|
+
of occasional dedup misses, never duplicates by construction.
|
|
334
|
+
|
|
335
|
+
## Caps
|
|
336
|
+
|
|
337
|
+
`output_path` validation, app-string length, intent length all carry
|
|
338
|
+
through from §13.3. The daemon enforces them at PATCH time; if the
|
|
339
|
+
fetched data violates them (rare — usually upstream titles too long),
|
|
340
|
+
truncate the offending field and surface a one-line warning in the
|
|
341
|
+
appended `## <App> Notes` body, not as a separate DM.
|
|
342
|
+
|
|
343
|
+
## Error envelope
|
|
344
|
+
|
|
345
|
+
| HTTP | `error` | What to do |
|
|
346
|
+
|---|---|---|
|
|
347
|
+
| 400 (`/api/managed-tasks/:id/run-result`) | `invalid_id` / `validation_error` | Body shape drift — re-check field names exactly match `last_run_at` / `last_result` / `consecutive_failures` |
|
|
348
|
+
| 403 (`/api/context/<domain>/<type-plural>/...`) | `forbidden` | Entity-domain write paths are not yet whitelisted (Phase 5 gap, §Step 5a). Skip the entity merge for this run, still record run-result, and surface a one-line warning in `last_result`. |
|
|
349
|
+
| 404 (`/api/managed-tasks/:id`) | `not_found` | Row was stopped mid-run. End the session quietly. |
|
|
350
|
+
| 422 (`/api/context/...`) | `validation_error` | Frontmatter incomplete or malformed; populate all required fields and retry once |
|
|
351
|
+
| 422 (`/api/managed-tasks/:id`) | `validation_error` | Path / body shape rejected; drop the offending field (typically `output_path`) and retry once with the rest |
|
|
352
|
+
| 5xx | `internal_error` | Record `last_result='failed: <body.message>'` via Step 5b's failure form and end the session |
|
|
353
|
+
|
|
354
|
+
## What this skill does NOT do
|
|
355
|
+
|
|
356
|
+
- Does NOT post `/api/notify` for routine successes (silent by design).
|
|
357
|
+
- Does NOT post `/api/notify` for routine failures (final text empty).
|
|
358
|
+
The exception is the 3-strikes crossing — see Step 6: until the
|
|
359
|
+
daemon owns the threshold notify, the agent emits one DM at the
|
|
360
|
+
3rd consecutive failure, then stays silent until success or stop.
|
|
361
|
+
- Does NOT touch the §B row's `app` or `cadence` — those are
|
|
362
|
+
user-mutable only via `management-task-modify`.
|
|
363
|
+
- Does NOT INSERT `agent_schedule` rows. The cron scheduler does.
|
|
364
|
+
- Does NOT delete entity files when a tool returns "this item was
|
|
365
|
+
removed upstream". Removal-from-source is recorded as a
|
|
366
|
+
`frontmatter.sources.<app>.deleted_at` annotation, not a file
|
|
367
|
+
delete (the user's notes might still be valuable).
|
|
368
|
+
- Does NOT call any skill outside the read-only context API + the
|
|
369
|
+
selected backend tool. Specifically: no `management-task-*`
|
|
370
|
+
variant, no `schedule` mutation, no `roadmap` write.
|
|
371
|
+
- Does NOT include the row's `output_path` change in Step 5b unless
|
|
372
|
+
the run actually produced data confirming the path. Speculative
|
|
373
|
+
back-fill is forbidden.
|
|
374
|
+
|
|
375
|
+
## API summary
|
|
376
|
+
|
|
377
|
+
| Verb + path | Used in |
|
|
378
|
+
|---|---|
|
|
379
|
+
| `GET /api/managed-tasks/:id` | Step 1 (response wraps row in `{item}`) |
|
|
380
|
+
| `GET /api/entities?source=&external_id=` | Step 4.1 (tier-1 exact) |
|
|
381
|
+
| `GET /api/entities?source=` | Step 4 bias hint (list-by-source-key) |
|
|
382
|
+
| `GET /api/entities?domain=&type=&date=&q=` | Step 4.2 (tier-2 fuzzy) |
|
|
383
|
+
| `GET /api/entities/by-path?path=` | Step 4 (verify before merging) |
|
|
384
|
+
| `PATCH /api/context/<domain>/<type-plural>/<slug>` | Step 5a (gated by entity-domain write whitelist — Phase 5 gap) |
|
|
385
|
+
| `PATCH /api/managed-tasks/:id/run-result` | Step 5b (internal — last_run_at / last_result / consecutive_failures) |
|
|
386
|
+
| `PATCH /api/managed-tasks/:id` | Step 5b output-path back-fill only |
|
|
387
|
+
| `POST /api/notify` | Step 6 (only on the 3-failures-in-a-row crossing edge) |
|
|
388
|
+
|
|
389
|
+
The PATCH on `/api/managed-tasks/:id/run-result` writes one
|
|
390
|
+
`agent_actions` row (`management_task.run_recorded`); the §B render
|
|
391
|
+
and snapshot are the daemon's job. Do NOT post a separate audit
|
|
392
|
+
event.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: today
|
|
3
|
+
description: Load for any event that reads or writes today.md — morning routines, hourly checks, DMs, scheduled tasks. Owns the day-type filter, Agent Plan contract, Agent Log/Notes schema, schedule.approaching format, and Morning Routine lock.
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Bash(curl *)
|
|
6
|
+
- Read
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# today.md Guide
|
|
10
|
+
|
|
11
|
+
today.md has a **day-type header line** (second line) and **six required sections**.
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
# YYYY-MM-DD (day-of-week)
|
|
15
|
+
> Day type: Weekday | Work focus: on | Study focus: on | Personal focus: on
|
|
16
|
+
|
|
17
|
+
## User Schedule
|
|
18
|
+
## User Tasks
|
|
19
|
+
## Agent Plan
|
|
20
|
+
## Agent Notes
|
|
21
|
+
## Agent Log
|
|
22
|
+
## Handoff
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Line 1 — which date?
|
|
26
|
+
|
|
27
|
+
Always copy the date from the prompt's `<current_agent_day date="…" weekday="…" boundary_hour="…" />`.
|
|
28
|
+
That attribute is the **agent-day date**, not the calendar date — they
|
|
29
|
+
diverge between local midnight and `boundary_hour:00` local. Use the
|
|
30
|
+
attribute value verbatim:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
# <current_agent_day.date> (<current_agent_day.weekday>)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
So when the prompt context contains
|
|
37
|
+
`<current_agent_day date="2026-04-28" weekday="Tuesday" boundary_hour="4" />`,
|
|
38
|
+
line 1 is exactly `# 2026-04-28 (Tuesday)`. Do **not** advance the date
|
|
39
|
+
because the routine is "preparing tomorrow"; the morning routine always
|
|
40
|
+
prepares the agent-day in progress, not the next one.
|
|
41
|
+
|
|
42
|
+
`PUT /api/context/today` returns 422 if line 1 disagrees with the
|
|
43
|
+
daemon's current agent-day; the error message echoes both values so a
|
|
44
|
+
mistake is recoverable in the same session.
|
|
45
|
+
|
|
46
|
+
today.md has **no YAML frontmatter** — the H1 must be the first byte of
|
|
47
|
+
the file.
|
|
48
|
+
|
|
49
|
+
## Header line — day-type filter
|
|
50
|
+
|
|
51
|
+
Line 2 encodes today's filter policy (field order is fixed — downstream parsers rely on it):
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
> Day type: {Weekday|Weekend} | Work focus: {on|off} | Study focus: {on|off} | Personal focus: {on|off}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Derivation (Morning Routine at 04:00):
|
|
58
|
+
1. Day-of-week from `<current_time>`. Weekday = Mon–Fri, Weekend = Sat–Sun (unless user/profile.md overrides).
|
|
59
|
+
2. Read `user/profile.md` → ## Notification Preferences. Apply matching policy.
|
|
60
|
+
3. No explicit policy → default: weekday = all on, weekend = work off, study on, personal on.
|
|
61
|
+
|
|
62
|
+
Category → focus-dimension mapping:
|
|
63
|
+
|
|
64
|
+
| Category tag | Controlled by |
|
|
65
|
+
|---|---|
|
|
66
|
+
| `[work]` | Work focus |
|
|
67
|
+
| `[study]` | Study focus |
|
|
68
|
+
| `[personal]`, `[home]` | Personal focus |
|
|
69
|
+
|
|
70
|
+
How downstream events use it:
|
|
71
|
+
- Morning Routine suppresses items with focus `off` at generation time
|
|
72
|
+
- scheduled.task re-checks at fire time: if focus is off, skip + close as `skipped (focus off)`
|
|
73
|
+
- DM handler skips follow-ups on rows whose focus is off
|
|
74
|
+
- Hourly check drops observations whose focus is off
|
|
75
|
+
- schedule.approaching suppresses notifications for off categories
|
|
76
|
+
|
|
77
|
+
## Sections and when to update
|
|
78
|
+
|
|
79
|
+
| Section | When to update | Mode | Who writes |
|
|
80
|
+
|---|---|---|---|
|
|
81
|
+
| `user_schedule` | Morning from calendar; refresh after sync | PUT (Morning) / PATCH replace | Morning primary |
|
|
82
|
+
| `user_tasks` | Status changes, new tasks, hourly observations | PATCH append (new) / replace (flip) | Morning + event-driven |
|
|
83
|
+
| `agent_plan` | Morning lays out actions; hourly adds new; scheduled.task flips `[x]` | PATCH append / replace (flip) | Morning + hourly + scheduled.task |
|
|
84
|
+
| `agent_notes` | Look-ahead + day-time events | PATCH append | Morning (look-ahead) + event-driven |
|
|
85
|
+
| `agent_log` | Every non-trivial agent action | PATCH append | All events |
|
|
86
|
+
| `handoff` | Evening Review finalizes carry-overs | PATCH replace | Evening Review only |
|
|
87
|
+
|
|
88
|
+
## Entry formats
|
|
89
|
+
|
|
90
|
+
| Section | Format | Example |
|
|
91
|
+
|---|---|---|
|
|
92
|
+
| `user_schedule` | `- HH:MM[–HH:MM] <title> [category]` | `- 14:00–15:00 Design review [work]` |
|
|
93
|
+
| `user_tasks` | `- [ ] HH:MM <description> [category]` | `- [ ] 11:00 Finalize Q2 draft [work]` |
|
|
94
|
+
| `agent_plan` | `- [ ] HH:MM <action> [category] →<trigger>` | `- [ ] 08:55 DM reminder: standup [work] →DM` |
|
|
95
|
+
| `agent_notes` | see flavors below | |
|
|
96
|
+
| `agent_log` | `- HH:MM <action description>` | `- 13:50 [cal] Design review — reminder sent` |
|
|
97
|
+
|
|
98
|
+
**Category tags**: `[work]`, `[study]`, `[personal]`, `[home]` — mandatory on Agent Plan rows (not decorative).
|
|
99
|
+
|
|
100
|
+
**Trigger tags** (Agent Plan only): `→DM`, `→notify`, `→check-in`, `→wake`
|
|
101
|
+
|
|
102
|
+
**HH:MM is mandatory** on User Tasks and Agent Plan rows. If no natural time: (1) deadline → 2h before, (2) calendar-adjacent → 15 min before, (3) otherwise → working-hours midpoint.
|
|
103
|
+
|
|
104
|
+
## User Tasks vs Agent Plan
|
|
105
|
+
|
|
106
|
+
User Tasks = things the **user** will do.
|
|
107
|
+
Agent Plan = things **Claude Code** will do to help the user.
|
|
108
|
+
|
|
109
|
+
## Agent Plan contract
|
|
110
|
+
|
|
111
|
+
1. Every Agent Plan row MUST be backed by exactly one `POST /api/schedule` that fires at the stated HH:MM.
|
|
112
|
+
2. Every planned outbound reminder/DM/check-in MUST appear as a row so the user can audit it.
|
|
113
|
+
3. When the scheduled wake-up fires, the handler MUST close the loop (see lifecycle below).
|
|
114
|
+
|
|
115
|
+
Violations: row without schedule → silently never fires. Schedule without row → invisible work. Past `[ ]` row → bug or de-registered.
|
|
116
|
+
|
|
117
|
+
## Agent Plan lifecycle — close the loop
|
|
118
|
+
|
|
119
|
+
When spawned by a `scheduled.task` for an Agent Plan row:
|
|
120
|
+
|
|
121
|
+
1. Execute the task (send DM, fire notification, run check-in).
|
|
122
|
+
2. Append to Agent Log: `- HH:MM [agent_plan] <action> — <outcome>`
|
|
123
|
+
Outcomes: `DM sent`, `notify sent`, `skipped (user in meeting)`, `failed: <reason>`
|
|
124
|
+
3. Read today.md, locate the matching Agent Plan row (match HH:MM + action text), flip `[ ]` → `[x]`:
|
|
125
|
+
```bash
|
|
126
|
+
curl -s http://localhost:8321/api/context/today
|
|
127
|
+
# Edit the agent_plan section body, then:
|
|
128
|
+
curl -s -X PATCH http://localhost:8321/api/context/today \
|
|
129
|
+
-H 'Content-Type: application/json' \
|
|
130
|
+
-d '{"section": "agent_plan", "mode": "replace", "content": "- [x] 08:55 ..."}'
|
|
131
|
+
```
|
|
132
|
+
**Read-before-write is mandatory** — PATCH replace replaces the entire section.
|
|
133
|
+
4. If the Agent Plan row is missing (user hand-edited), log and skip.
|
|
134
|
+
5. Always flip to `[x]`, even for skips/failures — annotate non-success:
|
|
135
|
+
- Success: no annotation
|
|
136
|
+
- Skip: `⚠ skipped: <reason>`
|
|
137
|
+
- Failure: `⚠ failed: <reason>`
|
|
138
|
+
6. If PATCH returns 409 (Morning Routine lock), retry after 30s up to 3 times. If still locked, log `loop-closeout deferred`.
|
|
139
|
+
|
|
140
|
+
**Why flip inside the scheduled task, not later?** The user may DM at 09:00 asking "did you send the reminder?" — if the row is still `[ ]`, the DM handler can't tell whether it was sent.
|
|
141
|
+
|
|
142
|
+
## Agent Log format
|
|
143
|
+
|
|
144
|
+
`- HH:MM Action description`. Log every user-visible action, context file write, or outbound API call. Skip purely internal no-ops.
|
|
145
|
+
|
|
146
|
+
## Agent Notes flavors
|
|
147
|
+
|
|
148
|
+
- **Look-ahead** (Morning Routine): `- [ ] (HIGH/MID/LOW) description — reasoning`
|
|
149
|
+
- **Day-time observations**: `- Source: summary of notable change`
|
|
150
|
+
- **Latent profile question** (Morning Routine Step 7.5):
|
|
151
|
+
`- Profile question (latent): <id> — wait for natural opportunity`
|
|
152
|
+
Flipped to `- Profile question (asked HH:MM): <id>` by the DM
|
|
153
|
+
handler / morning briefing when the question is woven into a reply.
|
|
154
|
+
Not an Agent Plan row — does NOT carry a leading HH:MM and is NOT
|
|
155
|
+
backed by a schedule entry. The question is opportunistic, not
|
|
156
|
+
scheduled. The parenthetical `(latent)` / `(asked HH:MM)` is the
|
|
157
|
+
state field; the LLM finds the line by matching the
|
|
158
|
+
`Profile question (latent): <id>` prefix. See the **user-interview**
|
|
159
|
+
skill for the full lifecycle.
|
|
160
|
+
|
|
161
|
+
## schedule.approaching → Agent Notes + Agent Log
|
|
162
|
+
|
|
163
|
+
The firing flow gates timing — `schedule.approaching` only fires at
|
|
164
|
+
`minutesUntil <= 15` (`packages/daemon/src/observers/calendar-poller.ts:125`),
|
|
165
|
+
so the LLM never sees this format-using event with a wider lookahead.
|
|
166
|
+
No additional gate is restated here.
|
|
167
|
+
|
|
168
|
+
**Agent Notes**:
|
|
169
|
+
`- 📅 event_title starts at HH:MM [— blocks/relates to: <task>]`
|
|
170
|
+
|
|
171
|
+
**Agent Log** (always):
|
|
172
|
+
`- HH:MM [cal] event_title — action`
|
|
173
|
+
|
|
174
|
+
## Morning Routine lock
|
|
175
|
+
|
|
176
|
+
Morning Routine acquires exclusive lock. Other sessions get 409 on PUT/PATCH (GET always allowed). If `<today_write_lock_id>` is in context, include `X-Lock-Id` header on every PUT/PATCH. Lock auto-releases on daemon timeout.
|
|
177
|
+
|
|
178
|
+
PUT today.md must contain the H1 date line, day-type header quote, and all six sections in order.
|
|
179
|
+
|
|
180
|
+
## today.md API (subset of context API)
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
curl -s http://localhost:8321/api/context/today # Read
|
|
184
|
+
curl -s -X PUT http://localhost:8321/api/context/today \ # Full replace (Morning only)
|
|
185
|
+
-H 'Content-Type: application/json' -d '{"content": "# 2026-04-02 (Thu)\n..."}'
|
|
186
|
+
curl -s -X PATCH http://localhost:8321/api/context/today \ # Section operation
|
|
187
|
+
-H 'Content-Type: application/json' -d '{"section": "agent_log", "mode": "append", "content": "- 09:35 ..."}'
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Add `X-Lock-Id` header if `<today_write_lock_id>` is in context. See context skill for full API reference.
|
|
191
|
+
|
|
192
|
+
## Knowledge map — section shape (auto-curated)
|
|
193
|
+
|
|
194
|
+
<!-- CURATION:knowledge_layout id="section-shape" -->
|
|
195
|
+
|
|
196
|
+
## Agent Notes flavors (auto-curated)
|
|
197
|
+
|
|
198
|
+
<!-- CURATION:convention_notes id="agent-notes-flavors" -->
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"sections": [
|
|
4
|
+
{
|
|
5
|
+
"id": "section-shape",
|
|
6
|
+
"kind": "knowledge_layout",
|
|
7
|
+
"anchor": "<!-- CURATION:knowledge_layout id=\"section-shape\" -->",
|
|
8
|
+
"human_label": "today.md section shape",
|
|
9
|
+
"description": "Required sections in today.md and what each holds",
|
|
10
|
+
"scope_paths": ["today.md"]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "agent-notes-flavors",
|
|
14
|
+
"kind": "convention_notes",
|
|
15
|
+
"anchor": "<!-- CURATION:convention_notes id=\"agent-notes-flavors\" -->",
|
|
16
|
+
"human_label": "Agent Notes flavors",
|
|
17
|
+
"description": "Sub-shapes the agent uses inside ## Agent Notes (look-ahead, day-time observation, latent profile question)",
|
|
18
|
+
"scope_paths": ["today.md"]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "convention_notes",
|
|
3
|
+
"notes": [
|
|
4
|
+
{
|
|
5
|
+
"topic": "Look-ahead",
|
|
6
|
+
"rule": "Look-ahead notes flag a future event the user may want to prepare for, written as a single bullet under ## Agent Notes."
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"topic": "Day-time observation",
|
|
10
|
+
"rule": "Day-time observations capture something the user said or did during the day that is worth surfacing later, often in the next morning routine."
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"topic": "Latent profile question",
|
|
14
|
+
"rule": "Latent profile questions are open questions the agent wants to ask the user when context allows, marked with the suffix `(asked HH:MM)` once asked."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "knowledge_layout",
|
|
3
|
+
"files": [
|
|
4
|
+
{
|
|
5
|
+
"path": "today.md",
|
|
6
|
+
"purpose": "today's plan, schedule, agent log, and handoff to tomorrow",
|
|
7
|
+
"sections": [
|
|
8
|
+
{ "heading": "## Plan", "contains": "the day's intent in plain prose" },
|
|
9
|
+
{ "heading": "## Schedule", "contains": "time-blocked events for today" },
|
|
10
|
+
{ "heading": "## Tasks", "contains": "open task entries with status checkbox" },
|
|
11
|
+
{ "heading": "## Agent Notes", "contains": "look-aheads, day-time observations, latent profile questions" },
|
|
12
|
+
{ "heading": "## Handoff", "contains": "context for tomorrow's morning routine" },
|
|
13
|
+
{ "heading": "## Done", "contains": "tasks the user marked complete" }
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|