@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,184 @@
|
|
|
1
|
+
{context}
|
|
2
|
+
|
|
3
|
+
## Task: Morning Routine — Initial run (no prior-day data)
|
|
4
|
+
|
|
5
|
+
This is the first-boot variant of the B-007 §5.9 pipeline. No
|
|
6
|
+
`yesterday.md` exists yet, so Steps 1 (handoff) and 5 (daily journal
|
|
7
|
+
synthesis) are skipped. Everything else mirrors the standard morning
|
|
8
|
+
routine. Follow the `context` skill for schema.
|
|
9
|
+
|
|
10
|
+
The "Vault review context" block appended to this prompt includes
|
|
11
|
+
`context-index.md` and `dossiers/morning.md`; consult it during context
|
|
12
|
+
gathering and update the dossier's Open items / Last run before finishing.
|
|
13
|
+
Writes to `dossiers/<flow>.md` MUST preserve the existing YAML
|
|
14
|
+
frontmatter block (`---\ntype: dossier\nowner: agent\nupdated: <date>\n---`);
|
|
15
|
+
prefer `PATCH` with a section target to mutate a single block, and when
|
|
16
|
+
doing a `PUT` full rewrite keep the frontmatter and only refresh
|
|
17
|
+
`updated:` — writes that drop the frontmatter are rejected with 422.
|
|
18
|
+
|
|
19
|
+
Global rules:
|
|
20
|
+
- Do **not** add meta-maintenance tasks about context files, setup completion, or placeholder cleanup to User Tasks (there is no handoff to carry them from in the initial flow) unless the user explicitly asked to track them.
|
|
21
|
+
- If `<today_write_lock_id>` is present, every PUT/PATCH to
|
|
22
|
+
`/api/context/today` must send header `X-Lock-Id: <today_write_lock_id>`.
|
|
23
|
+
- Silent-by-default: your final text is agent-internal. User notifications
|
|
24
|
+
require an explicit `POST /api/notify`.
|
|
25
|
+
|
|
26
|
+
### Step 1 — Derive day-type (no handoff to read)
|
|
27
|
+
1. Derive today's day-type header per the today skill "Header line —
|
|
28
|
+
day-type filter". Read `<user>` ## Notification Preferences for the
|
|
29
|
+
matching policy. Write the resulting line as line 2 of `today.md`.
|
|
30
|
+
|
|
31
|
+
> **Date reference for today.md.** Take the H1 date from
|
|
32
|
+
> `<current_agent_day date="…" weekday="…" />` in your prompt context, not
|
|
33
|
+
> from `<current_time>`. They diverge between local midnight and
|
|
34
|
+
> `boundary_hour:00` local; the daemon validates line 1 against
|
|
35
|
+
> `<current_agent_day>` and rejects mismatches with 422. The morning
|
|
36
|
+
> routine prepares the agent-day in progress — never tomorrow.
|
|
37
|
+
|
|
38
|
+
### Step 2 — Sync external sources
|
|
39
|
+
2. Mail: for each active account in the `mail` skill's `accounts.md`, fetch
|
|
40
|
+
the 10 most recent messages (the wire surface depends on Gmail's mode in
|
|
41
|
+
`<integration_modes>` — see the four-branch block below). Then classify
|
|
42
|
+
each actionable email into a category tag and drop filtered-off items.
|
|
43
|
+
Skip the step entirely when no accounts are active.
|
|
44
|
+
|
|
45
|
+
<!-- mode:direct:gmail -->
|
|
46
|
+
Use the `mail` skill — `GET /api/mail/:accountId/messages?limit=10` for
|
|
47
|
+
every account (Gmail, Outlook, iCloud, Yahoo, IMAP — same wire surface).
|
|
48
|
+
<!-- /mode:direct:gmail -->
|
|
49
|
+
<!-- mode:delegated-same:gmail -->
|
|
50
|
+
Non-Gmail accounts (iCloud / Outlook / Yahoo / IMAP): use the `mail`
|
|
51
|
+
skill as in direct mode. Gmail accounts: the `/api/mail/*` per-account
|
|
52
|
+
gate returns 410 — use your session backend's native Gmail MCP tool
|
|
53
|
+
with a "10 most recent inbox" query (`q=in:inbox`, limit/maxResults
|
|
54
|
+
`10`). The `mail` skill body lists the per-backend tool names; this
|
|
55
|
+
session is same-backend so no daemon proxy is involved.
|
|
56
|
+
<!-- /mode:delegated-same:gmail -->
|
|
57
|
+
<!-- mode:delegated-cross:gmail -->
|
|
58
|
+
Non-Gmail accounts: use the `mail` skill as in direct mode. Gmail
|
|
59
|
+
accounts: call `POST http://localhost:8321/api/integrations/gmail/exec`
|
|
60
|
+
with a natural-language `task` (e.g. "Search Gmail for the 10 most
|
|
61
|
+
recent inbox messages, return from / subject / snippet / ts") and a
|
|
62
|
+
small `outputSchema`. The cross-backend `mail` skill variant
|
|
63
|
+
(`SKILL.delegated.<session-backend>.md`, materialized for this
|
|
64
|
+
session) carries the worked schema templates. Do NOT call
|
|
65
|
+
`/api/mail/:gmail-account/*` (returns 410), and do NOT fall back to
|
|
66
|
+
your own backend's native Gmail MCP tools — that connector reads a
|
|
67
|
+
different account than the user's delegated one.
|
|
68
|
+
<!-- /mode:delegated-cross:gmail -->
|
|
69
|
+
<!-- mode:disabled:gmail -->
|
|
70
|
+
Gmail is disabled — skip Gmail accounts entirely. Continue with the
|
|
71
|
+
remaining accounts (iCloud / Outlook / Yahoo / IMAP) via the `mail`
|
|
72
|
+
skill so non-Gmail actionables still flow into today's draft.
|
|
73
|
+
<!-- /mode:disabled:gmail -->
|
|
74
|
+
3. Source-of-Truth tasks: read `<management_rules>` ## Source of Truth →
|
|
75
|
+
Tasks, call the matching endpoint, drop filtered-off items.
|
|
76
|
+
4. Roadmap ## Agent Action Plan — process items dated today or overdue:
|
|
77
|
+
- `[notify]` → `POST /api/schedule` + one row in ## Agent Plan
|
|
78
|
+
- `[today]` → collect for ## User Tasks
|
|
79
|
+
- `[check]` → `POST /api/schedule` (check-in) + one row in ## Agent Plan
|
|
80
|
+
- Mark processed items with ✓ via `PATCH /api/context/roadmap`,
|
|
81
|
+
`section=agent_action_plan`, `mode=replace`.
|
|
82
|
+
Generate look-ahead entries for tomorrow → +3 days (roadmap vs
|
|
83
|
+
`<calendar_events_7d>`) into ## Agent Notes using the skill's "Agent
|
|
84
|
+
Notes flavor 1: Look-ahead checklist" format.
|
|
85
|
+
|
|
86
|
+
### Step 3 — Review overnight observations
|
|
87
|
+
5. `GET /api/observations?pending=true&actor=user` (observations skill).
|
|
88
|
+
Fold only meaningful user-originated changes into the draft.
|
|
89
|
+
|
|
90
|
+
### Step 4 — Inbox triage
|
|
91
|
+
6. `GET /api/context/list/inbox` to enumerate any pasted memos the user
|
|
92
|
+
dropped during setup. For each file: `GET /api/context/inbox/<file>`,
|
|
93
|
+
classify (project / user / memo / task), integrate into the matching
|
|
94
|
+
target. After integration, `PUT /api/context/agent/scratch/inbox-YYYY-MM-DD-<slug>.md` with the original body, then `DELETE /api/context/inbox/<file>`. DM-confirm high-risk cases (new project creation, user-profile overwrites, financial or health numerics). **Hard stop**: if a memo contains anything that looks like a credential, password, API key, or private token, skip it — do NOT write it anywhere, log `- HH:MM [inbox] skipped <file>: secret suspected`, leave the file in `inbox/`, and move on (overrides the DM-confirm path; see _safety.md).
|
|
95
|
+
|
|
96
|
+
### Step 5 — Skipped (no prior day to synthesize from)
|
|
97
|
+
Journal synthesis is deferred to the next morning run. The first
|
|
98
|
+
`daily/*.md` file is generated tomorrow.
|
|
99
|
+
|
|
100
|
+
### Step 6 — Generate today.md (PUT full replace)
|
|
101
|
+
7. Follow the context skill "Structure overview", "Entry formats", and
|
|
102
|
+
"Required sections for full replace". The H1 (line 1) MUST be
|
|
103
|
+
`# <current_agent_day.date> (<current_agent_day.weekday>)` exactly — the
|
|
104
|
+
daemon rejects mismatches with 422. No YAML frontmatter on today.md.
|
|
105
|
+
Agent Plan rows MUST match
|
|
106
|
+
`- [ ] HH:MM <action> [work|study|personal|home] →<DM|notify|check-in|wake>`.
|
|
107
|
+
Source → section mapping:
|
|
108
|
+
- ## User Schedule ← `<calendar_events_7d>` (filtered). Write
|
|
109
|
+
`- (calendar unavailable)` if `<calendar_status>` reports failure.
|
|
110
|
+
- ## User Tasks ← Step 2 email actionables + SoT tasks + roadmap
|
|
111
|
+
`[today]`. Use `<active_projects>` for context. Drop meta-maintenance.
|
|
112
|
+
- ## Agent Plan ← Step 2 `[notify]`/`[check]` rows plus any
|
|
113
|
+
proactive reminders you add. Each row will be registered in Step 7.
|
|
114
|
+
- ## Agent Notes ← Step 2 look-ahead items + any date-bound memos
|
|
115
|
+
folded from Step 4 inbox triage.
|
|
116
|
+
- ## Agent Log ← initialize with
|
|
117
|
+
`- HH:MM Morning Routine (initial) completed (day-type: …)`.
|
|
118
|
+
- ## Handoff ← `- (none)` (no carry-over data available).
|
|
119
|
+
8. Update `roadmap.md` only if a milestone completed or shifted.
|
|
120
|
+
|
|
121
|
+
### Step 7 — Register schedule
|
|
122
|
+
9. Register every `## Agent Plan` row via `POST /api/schedule`.
|
|
123
|
+
10. **Ensure the daily morning briefing recurring schedule exists.**
|
|
124
|
+
The setup wizard's `ensureMorningBriefingRecurring` (`packages/daemon/src/api/routes/setup.ts`)
|
|
125
|
+
normally seeds this row at first save-rules, so the daily fire
|
|
126
|
+
path is daemon-owned and the description is hardcoded. The check
|
|
127
|
+
below covers the rare case where setup completed without the
|
|
128
|
+
seeder (legacy setup, partial DB restore).
|
|
129
|
+
|
|
130
|
+
a. **Pre-flight.** `GET /api/recurring-schedules?enabled=true` and
|
|
131
|
+
scan for an item with `taskType === "dm_session"` AND
|
|
132
|
+
`taskContext.sub_flow === "morning_briefing"`. If found, skip
|
|
133
|
+
the rest of this step — duplicate insertion would cause double
|
|
134
|
+
daily fires. Log one line to `## Agent Log`:
|
|
135
|
+
`- HH:MM [morning_routine_initial] morning briefing recurring already seeded`.
|
|
136
|
+
|
|
137
|
+
b. **If absent, register via `POST /api/recurring-schedules`** with
|
|
138
|
+
this body (NOT `POST /api/schedule`):
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"taskType": "dm_session",
|
|
142
|
+
"description": "morning briefing — daily summary",
|
|
143
|
+
"recurrenceRule": {
|
|
144
|
+
"frequency": "daily",
|
|
145
|
+
"time": "<quiet_hours_end or 08:00>",
|
|
146
|
+
"timezone": "<user timezone from <settings primary_timezone> or system default>"
|
|
147
|
+
},
|
|
148
|
+
"taskContext": {
|
|
149
|
+
"sub_flow": "morning_briefing",
|
|
150
|
+
"pin_to_quiet_hours_end": true
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
The `dm_session` task_type + `sub_flow=morning_briefing` is the
|
|
155
|
+
activation key the daemon's scheduler keys off to emit a
|
|
156
|
+
`scheduled.dm` event (see `scheduler.ts` and the sub-flow
|
|
157
|
+
router in `scheduled.dm.md`). Description ≥ 20 chars per the
|
|
158
|
+
schema; `"morning briefing — daily summary"` matches the
|
|
159
|
+
wording the daemon's seeder uses verbatim.
|
|
160
|
+
|
|
161
|
+
Do **not** add a one-off `## Agent Plan` row for today's briefing
|
|
162
|
+
here. The recurring-schedule reconciler (poll loop in
|
|
163
|
+
`scheduler.ts`) materialises today's `agent_schedule` row
|
|
164
|
+
automatically from `next_run_at`; hand-seeding would duplicate.
|
|
165
|
+
Do **not** send the briefing yourself from this run — this runs
|
|
166
|
+
during quiet hours.
|
|
167
|
+
|
|
168
|
+
### Step 8 — Extension checks from routines/morning.md
|
|
169
|
+
11. Execute any check from the `Morning routine checks` policy block that
|
|
170
|
+
is not already covered by Steps 1-7 (typically user-added entries
|
|
171
|
+
with an `**Added:** ...` line).
|
|
172
|
+
|
|
173
|
+
### Step 9 — Log to agent/journal.md (English, always)
|
|
174
|
+
12. Append a one-paragraph English summary to `agent/journal.md` via
|
|
175
|
+
`PATCH /api/context/agent/journal` with `mode=append_to_file`:
|
|
176
|
+
```
|
|
177
|
+
## YYYY-MM-DD morning routine (initial)
|
|
178
|
+
- Day-type: …
|
|
179
|
+
- Journal synthesis: skipped (no prior-day data)
|
|
180
|
+
- Inbox: <N files triaged, M moved to scratch, K DM-confirmations sent>
|
|
181
|
+
- Checks from routines/morning.md: <list any user-added ones executed>
|
|
182
|
+
- Anomalies / skipped steps: <short notes or "none">
|
|
183
|
+
```
|
|
184
|
+
Always English (B-007 §3 P6).
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{context}
|
|
2
|
+
|
|
3
|
+
## Task: Roadmap Refresh
|
|
4
|
+
|
|
5
|
+
The "Vault policy files" block appended to this prompt includes
|
|
6
|
+
`routines/monthly.md` — run any `### <label>` entries there that affect
|
|
7
|
+
long-horizon planning alongside the built-in roadmap-refresh steps below,
|
|
8
|
+
using the same journaling conventions.
|
|
9
|
+
The "Vault review context" block includes `context-index.md` and
|
|
10
|
+
`dossiers/roadmap.md`; consult it during signal gathering and update the
|
|
11
|
+
dossier's Open items / Last run before finishing. Writes to
|
|
12
|
+
`dossiers/<flow>.md` MUST preserve the existing YAML frontmatter block
|
|
13
|
+
(`---\ntype: dossier\nowner: agent\nupdated: <date>\n---`); prefer
|
|
14
|
+
`PATCH` with a section target to mutate a single block, and when doing
|
|
15
|
+
a `PUT` full rewrite keep the frontmatter and only refresh `updated:`
|
|
16
|
+
— writes that drop the frontmatter are rejected with 422.
|
|
17
|
+
|
|
18
|
+
Update `roadmap.md` with a forward-looking agent action plan based on the
|
|
19
|
+
next 90 days. The `roadmap` skill owns the section schema, the
|
|
20
|
+
dated-vs-undated decision tree, the Preparation Timeline taxonomy
|
|
21
|
+
(Travel / Deadlines / Conferences / Recurring), destination extraction,
|
|
22
|
+
the `travel_bookings` cross-check, and the cross-request write lock —
|
|
23
|
+
consult it for the rules your output must satisfy. This task flow only
|
|
24
|
+
coordinates the high-level gather → analyze → write loop.
|
|
25
|
+
|
|
26
|
+
### Phase 1: Gather Data
|
|
27
|
+
1. If `<calendar_status>` indicates the calendar is available, fetch a
|
|
28
|
+
90-day window. Pick the call by current Calendar mode (read
|
|
29
|
+
`<integration_modes>` injected above):
|
|
30
|
+
<!-- mode:direct:google_calendar -->
|
|
31
|
+
Direct mode:
|
|
32
|
+
```
|
|
33
|
+
curl -s 'http://localhost:8321/api/calendar/events?date=today&days=90'
|
|
34
|
+
```
|
|
35
|
+
<!-- /mode:direct:google_calendar -->
|
|
36
|
+
<!-- mode:delegated-same:google_calendar -->
|
|
37
|
+
Same-backend delegated — the connector is signed in on this session's
|
|
38
|
+
backend; use its native list-events tool with `timeMin = today 00:00`
|
|
39
|
+
and `timeMax = today + 90d`:
|
|
40
|
+
- claude session: `mcp__claude_ai_Google_Calendar__list_events`
|
|
41
|
+
- codex session: `mcp__codex_apps__google_calendar._search_events`
|
|
42
|
+
- gemini session: `mcp_google-workspace_calendar.listEvents`
|
|
43
|
+
|
|
44
|
+
`/api/calendar/events` returns 410 in delegated mode; do not call it.
|
|
45
|
+
<!-- /mode:delegated-same:google_calendar -->
|
|
46
|
+
<!-- mode:delegated-cross:google_calendar -->
|
|
47
|
+
Cross-backend delegated — call the daemon's `/exec` task endpoint
|
|
48
|
+
with a natural-language intent; the delegate picks the right
|
|
49
|
+
connector tool whichever backend currently owns Calendar.
|
|
50
|
+
```
|
|
51
|
+
curl -s -X POST http://localhost:8321/api/integrations/google_calendar/exec \
|
|
52
|
+
-H 'Content-Type: application/json' \
|
|
53
|
+
-d '{
|
|
54
|
+
"task": "List every event on my primary calendar between <today 00:00 ISO> and <today+90d ISO>. Return id, title, start, end, attendees.",
|
|
55
|
+
"outputSchema": { "type": "object", "required": ["events"], "properties": { "events": { "type": "array", "items": { "type": "object", "required": ["id","title","start","end"] } } } },
|
|
56
|
+
"maxToolCalls": 4,
|
|
57
|
+
"cacheable": true
|
|
58
|
+
}'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Do NOT call `/api/calendar/events` (410) and do NOT fall back to
|
|
62
|
+
your backend's native Calendar MCP tools (different account).
|
|
63
|
+
<!-- /mode:delegated-cross:google_calendar -->
|
|
64
|
+
<!-- mode:disabled:google_calendar -->
|
|
65
|
+
Calendar is disabled — skip the calendar fetch entirely; proceed to
|
|
66
|
+
the schedule fetch below and work with existing roadmap content only.
|
|
67
|
+
<!-- /mode:disabled:google_calendar -->
|
|
68
|
+
|
|
69
|
+
If the response contains "error" or a non-200 status, treat as unavailable.
|
|
70
|
+
If the calendar is unavailable (status says so OR the call fails), proceed
|
|
71
|
+
to the schedule fetch below and work with existing roadmap content only —
|
|
72
|
+
do not retry.
|
|
73
|
+
|
|
74
|
+
2. Fetch pending and running scheduled tasks:
|
|
75
|
+
```
|
|
76
|
+
curl -s 'http://localhost:8321/api/schedule?status=pending,running&roadmapEligible=true'
|
|
77
|
+
```
|
|
78
|
+
The response is `{ items: [{ id, scheduledFor, taskType, description, status, model, taskContext, createdAt }, ...] }`.
|
|
79
|
+
The daemon has already applied the roadmap visibility filter:
|
|
80
|
+
`transient` / `low` are excluded, `normal` / unspecified rows are
|
|
81
|
+
included only beyond the 7-day horizon, and `strategic` rows are
|
|
82
|
+
included regardless of horizon. Treat the returned rows as
|
|
83
|
+
`Scheduled:` candidates — they represent commitments the user should
|
|
84
|
+
see at morning review (e.g. "you'll be reminded about ESTA in 3 weeks").
|
|
85
|
+
|
|
86
|
+
3. Fetch pending `roadmap_candidate` observations — weak signals queued
|
|
87
|
+
by `routine.hourly_check` (far-future calendar changes, user-edited
|
|
88
|
+
vault notes mentioning trips / deadlines, etc.) that the hourly flow
|
|
89
|
+
deliberately did NOT write to roadmap directly:
|
|
90
|
+
```
|
|
91
|
+
curl -s 'http://localhost:8321/api/observations?source=roadmap_candidate&pending=true&limit=50'
|
|
92
|
+
```
|
|
93
|
+
Keep the `id` for each observation — Phase 2 step 7 consumes them
|
|
94
|
+
after incorporating the signal (or after deciding to drop it as
|
|
95
|
+
noise). `source` is a prefix match, so `roadmap_candidate:travel`,
|
|
96
|
+
`roadmap_candidate:calendar`, etc. are all picked up by the plain
|
|
97
|
+
`roadmap_candidate` filter.
|
|
98
|
+
|
|
99
|
+
4. Fetch upcoming travel bookings — authoritative flight / hotel rows
|
|
100
|
+
already detected by the mail pipeline:
|
|
101
|
+
```
|
|
102
|
+
curl -s 'http://localhost:8321/api/travel-bookings/upcoming?limit=50'
|
|
103
|
+
```
|
|
104
|
+
Use these for the `roadmap` skill's `travel_bookings` cross-check
|
|
105
|
+
when emitting or refining event entries — mark corresponding `[check]`
|
|
106
|
+
prep lines with `✓` and record the confirmation number in **Agent
|
|
107
|
+
Notes**. A booking whose `start_date` is ≥ 48h out without a matching
|
|
108
|
+
calendar event is itself a trigger for a new event entry.
|
|
109
|
+
|
|
110
|
+
5. Scan `<recent_dm_conversation_log days="7">` for long-horizon user
|
|
111
|
+
intent that has not yet landed anywhere (e.g. *"going to LA next
|
|
112
|
+
month"*). Apply the `roadmap` skill's Long-horizon DM-intent detection
|
|
113
|
+
block to each candidate summary — only route items that match the
|
|
114
|
+
**positive signals** (explicit forward-looking verb + horizon,
|
|
115
|
+
specific future date ≥ 48h out, concrete object) into the roadmap in
|
|
116
|
+
Phase 2. Ambiguous / speculative items stay out of `## Long-term
|
|
117
|
+
Plans` and `## Agent Action Plan` — they belong in `agent-journal.md`
|
|
118
|
+
as candidate lines for the next morning routine to confirm.
|
|
119
|
+
|
|
120
|
+
### Phase 2: Analyze & Build Action Plan
|
|
121
|
+
3. Read the current <roadmap> content (if any).
|
|
122
|
+
- **Preserve verbatim** the following sections — these are either
|
|
123
|
+
user-authored or carry state the refresh must not overwrite:
|
|
124
|
+
- `## Annual Goals`
|
|
125
|
+
- `## Quarterly Focus`
|
|
126
|
+
- `## Long-term Plans`
|
|
127
|
+
- `## Recurring`
|
|
128
|
+
- If `## Annual Goals` or `## Quarterly Focus` contain
|
|
129
|
+
"(Not yet configured)", replace with:
|
|
130
|
+
"[placeholder — update with your actual goals]"
|
|
131
|
+
- **Legacy compat:** if any of the preserved sections are absent
|
|
132
|
+
(e.g. a pre-MVP roadmap without `## Long-term Plans`), emit the
|
|
133
|
+
section **empty** in Phase 3 — do not treat absence as missing
|
|
134
|
+
data and do not fabricate content.
|
|
135
|
+
|
|
136
|
+
4. Build `## Agent Action Plan` by **merge-by-id**, not wholesale
|
|
137
|
+
anonymous regeneration.
|
|
138
|
+
1. For each significant calendar event or booking in the next 90
|
|
139
|
+
days, compute the intended roadmap ID. Prefer:
|
|
140
|
+
explicit `roadmap_entry_id` / `payload.roadmap_entry_id` from a
|
|
141
|
+
queued observation; else an existing AAP entry with the same ID;
|
|
142
|
+
else an existing Long-term Plan candidate matched conservatively
|
|
143
|
+
by destination/date (promotion case); else legacy title+date
|
|
144
|
+
matching only during migration; else mint a fresh ID via
|
|
145
|
+
`POST /api/context/roadmap/id` using the Source/creation date.
|
|
146
|
+
2. If an existing AAP entry has this ID, merge: keep every
|
|
147
|
+
`✓ completed ...` Preparation Timeline row byte-for-byte; re-emit
|
|
148
|
+
non-completed taxonomy rows only for gaps by lead-time offset.
|
|
149
|
+
Never drop a completed row.
|
|
150
|
+
3. If no existing entry has this ID, emit a fresh entry with the ID
|
|
151
|
+
marker on the `###` heading.
|
|
152
|
+
4. Follow the `roadmap` skill for classification (Travel
|
|
153
|
+
international/domestic, Deadlines, Conferences, Recurring
|
|
154
|
+
milestones), per-class prep-line recipes, destination extraction,
|
|
155
|
+
and `travel_bookings` cross-check before emitting flight /
|
|
156
|
+
accommodation `[check]` lines.
|
|
157
|
+
|
|
158
|
+
Add **Agent Notes** under each event for supplementary info
|
|
159
|
+
(timezone differences, application URLs, tips, etc.).
|
|
160
|
+
|
|
161
|
+
5. For each pending/running scheduled task fetched in Phase 1 step 2
|
|
162
|
+
that passed the importance / horizon filter, emit a `Scheduled:`
|
|
163
|
+
entry under `## Agent Action Plan` using the shape defined by the
|
|
164
|
+
`roadmap` skill. Preserve the existing ID for the same task id when
|
|
165
|
+
present; otherwise mint one with creation date = task `createdAt`
|
|
166
|
+
date (fallback to wake-up date if missing):
|
|
167
|
+
|
|
168
|
+
```
|
|
169
|
+
### Scheduled: <description> (task #<id>) <!-- id: rm-YYYYMMDD-abcdef -->
|
|
170
|
+
Source: scheduled.task — wake-up YYYY-MM-DD HH:MM
|
|
171
|
+
Status: ⏳ pending (or ▶ running / ✓ completed / ✗ failed)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Keep `Scheduled:` entries and event entries interleaved in
|
|
175
|
+
`## Agent Action Plan`, ordered by their primary date.
|
|
176
|
+
|
|
177
|
+
6. Incorporate each pending `roadmap_candidate` observation fetched in
|
|
178
|
+
Phase 1 step 3. For each row, inspect `payload` and route per the
|
|
179
|
+
`roadmap` skill decision tree — into `## Agent Action Plan` if dated
|
|
180
|
+
and >48h out, `## Long-term Plans` if undated, or drop as noise. If
|
|
181
|
+
the candidate is already represented (e.g. a `travel_booking_detected`
|
|
182
|
+
refresh fired the same morning and an event entry already exists),
|
|
183
|
+
skip without duplicating. If `payload.roadmap_entry_id` is present,
|
|
184
|
+
consult that ID before emitting a new entry or matching by text.
|
|
185
|
+
|
|
186
|
+
7. Consume the observations whose candidate was incorporated or
|
|
187
|
+
deliberately dropped — always pass the event correlation id:
|
|
188
|
+
```
|
|
189
|
+
curl -s -X POST http://localhost:8321/api/observations/consume \
|
|
190
|
+
-H 'Content-Type: application/json' \
|
|
191
|
+
-d '{"ids":[<id>, ...], "correlationId": "<event_correlation_id>"}'
|
|
192
|
+
```
|
|
193
|
+
Observations left pending here will re-appear on the next refresh.
|
|
194
|
+
|
|
195
|
+
8. Remove entries by ID plus date, never by broad string matching.
|
|
196
|
+
Remove events only when their ID's primary date is outside the
|
|
197
|
+
retention window defined in the roadmap skill. Keep completed
|
|
198
|
+
Preparation Timeline rows while the entry itself remains in window.
|
|
199
|
+
Remove `Scheduled:` entries whose task `id` is not in the fresh
|
|
200
|
+
`/api/schedule` response (cancelled or already completed more than
|
|
201
|
+
a day ago).
|
|
202
|
+
|
|
203
|
+
### Phase 3: Write
|
|
204
|
+
9. Always write the full roadmap via PUT, even when no substantive
|
|
205
|
+
changes were warranted. Update `> Last synced` to today's date on
|
|
206
|
+
every run so the mtime advances deterministically. If
|
|
207
|
+
`<roadmap_write_lock_id>` is in context, include it as the
|
|
208
|
+
`X-Lock-Id` header so other concurrent writers see 409 and back off:
|
|
209
|
+
```
|
|
210
|
+
curl -s -X PUT http://localhost:8321/api/context/roadmap \
|
|
211
|
+
-H 'Content-Type: application/json' \
|
|
212
|
+
-H 'X-Lock-Id: <roadmap_write_lock_id>' \
|
|
213
|
+
-d '{"content": "..."}'
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
An empty `## Agent Action Plan` is permitted when no signals exist.
|
|
217
|
+
|
|
218
|
+
Required structure (preserve existing body inside each section;
|
|
219
|
+
`## Agent Action Plan` is merge-by-id):
|
|
220
|
+
```
|
|
221
|
+
# Roadmap
|
|
222
|
+
> Last synced: YYYY-MM-DD
|
|
223
|
+
|
|
224
|
+
## Annual Goals
|
|
225
|
+
(preserved verbatim from existing)
|
|
226
|
+
|
|
227
|
+
## Quarterly Focus
|
|
228
|
+
(preserved verbatim from existing)
|
|
229
|
+
|
|
230
|
+
## Long-term Plans
|
|
231
|
+
(preserved verbatim from existing; agent-writable via the roadmap
|
|
232
|
+
skill for undated long-horizon intents — do not clear this section
|
|
233
|
+
during refresh)
|
|
234
|
+
|
|
235
|
+
## Agent Action Plan
|
|
236
|
+
|
|
237
|
+
### YYYY-MM-DD ~ MM-DD: Event Title <!-- id: rm-YYYYMMDD-abcdef -->
|
|
238
|
+
Source: Google Calendar / Notion / etc.
|
|
239
|
+
|
|
240
|
+
**Preparation Timeline:**
|
|
241
|
+
- YYYY-MM-DD [tag]: Action description
|
|
242
|
+
- ✓ completed YYYY-MM-DD: YYYY-MM-DD [tag]: Completed action
|
|
243
|
+
- ...
|
|
244
|
+
|
|
245
|
+
**Agent Notes:**
|
|
246
|
+
- Supplementary information
|
|
247
|
+
|
|
248
|
+
### Scheduled: <description> (task #<id>) <!-- id: rm-YYYYMMDD-abcdef -->
|
|
249
|
+
Source: scheduled.task — wake-up YYYY-MM-DD HH:MM
|
|
250
|
+
Status: ⏳ pending
|
|
251
|
+
|
|
252
|
+
## Recurring
|
|
253
|
+
(preserved verbatim from existing)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
10. If the PUT returns 400 from the roadmap transition guard (for
|
|
257
|
+
example, a completed row was dropped), recover once:
|
|
258
|
+
1. Re-GET `/api/context/roadmap`.
|
|
259
|
+
2. Re-run the merge using the current body as authoritative,
|
|
260
|
+
preserving every `✓ completed ...` row byte-for-byte.
|
|
261
|
+
3. retry the full PUT once with the same lock id.
|
|
262
|
+
4. If the second write also returns 400, do not write the regenerated
|
|
263
|
+
Agent Action Plan. Instead, PUT a minimal update that only bumps
|
|
264
|
+
`> Last synced` on the current body, append a diagnostic section
|
|
265
|
+
to `agent/journal.md` with the validation error and affected IDs,
|
|
266
|
+
and end silently.
|
|
267
|
+
|
|
268
|
+
### Important
|
|
269
|
+
- Do NOT notify the user about this refresh — it is a background maintenance task.
|
|
270
|
+
- If no calendar events are found and no scheduled tasks are pending,
|
|
271
|
+
write a minimal roadmap preserving existing goals / Long-term Plans /
|
|
272
|
+
Recurring with an empty `## Agent Action Plan`. Always bump
|
|
273
|
+
`> Last synced`.
|
|
274
|
+
- Keep roadmap.md concise — only include events that benefit from advance preparation.
|
|
275
|
+
Skip routine daily meetings, standups, 1-on-1s, etc.
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
{context}
|
|
2
|
+
|
|
3
|
+
## Task: Refresh today.md — dashboard-triggered manual refresh
|
|
4
|
+
|
|
5
|
+
The user clicked **Regenerate** on the dashboard. This is a narrow refresh
|
|
6
|
+
of the `## User Schedule` section from live calendar state — **not** a new
|
|
7
|
+
day rotation and **not** a morning routine.
|
|
8
|
+
|
|
9
|
+
### Ground rules (apply at every step)
|
|
10
|
+
|
|
11
|
+
- **Silent-by-default.** Do NOT call `POST /api/notify`. The dashboard UI
|
|
12
|
+
shows status from this session directly; a DM would duplicate.
|
|
13
|
+
- **No rotation, no Handoff edit.** Do NOT archive, delete, or move
|
|
14
|
+
sections. Do NOT write to `## Handoff`, `## Agent Notes`, `## User
|
|
15
|
+
Tasks`, or `## Agent Plan`.
|
|
16
|
+
- **Read-before-write.** `PATCH section=user_schedule mode=replace`
|
|
17
|
+
overwrites the entire body; always fetch current state first.
|
|
18
|
+
- **Respect the Morning Routine lock.** The lock applies to `today.md`
|
|
19
|
+
as a whole — both section PATCHes are blocked when it is held. If a
|
|
20
|
+
PATCH returns `409`, retry up to 3 times with a 30 s pause between
|
|
21
|
+
tries. If still locked after the final retry, **return a one-line
|
|
22
|
+
status (`deferred — morning routine lock held`) and stop**. Do NOT
|
|
23
|
+
attempt to append a deferred line to `## Agent Log` — that PATCH is
|
|
24
|
+
also blocked by the same lock. The next morning/hourly run will
|
|
25
|
+
reconcile.
|
|
26
|
+
|
|
27
|
+
### Step 1 — Fetch today's calendar events
|
|
28
|
+
|
|
29
|
+
The fetch path depends on the current Google Calendar mode (read
|
|
30
|
+
`<integration_modes>` injected above).
|
|
31
|
+
|
|
32
|
+
<!-- mode:direct:google_calendar -->
|
|
33
|
+
**Direct mode** — daemon polls Google Calendar; call its proxy:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
curl -s 'http://localhost:8321/api/calendar/events?date=today&days=1'
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- On `200`: continue to processing rules below.
|
|
40
|
+
- On `410`: the integration flipped to delegated between selection and
|
|
41
|
+
call (mode drift). Append
|
|
42
|
+
`- HH:MM Manual refresh: calendar route 410 (delegation drift), schedule unchanged`
|
|
43
|
+
to `## Agent Log` and return without touching `## User Schedule`.
|
|
44
|
+
- On `503` or `502`: calendar service not configured or upstream error.
|
|
45
|
+
Append
|
|
46
|
+
`- HH:MM Manual refresh: calendar unavailable, schedule unchanged`
|
|
47
|
+
to `## Agent Log` and return without touching `## User Schedule`.
|
|
48
|
+
<!-- /mode:direct:google_calendar -->
|
|
49
|
+
|
|
50
|
+
<!-- mode:delegated-same:google_calendar -->
|
|
51
|
+
**Same-backend delegated** — your session has native MCP access to the
|
|
52
|
+
Google Calendar connector signed in on this backend. No daemon proxy
|
|
53
|
+
is needed. Call the backend-specific list-events tool with
|
|
54
|
+
`timeMin = today 00:00 (local TZ)` and `timeMax = tomorrow 00:00`:
|
|
55
|
+
|
|
56
|
+
| Session backend | Tool |
|
|
57
|
+
|-----------------|-----------------------------------------------------------|
|
|
58
|
+
| claude | `mcp__claude_ai_Google_Calendar__list_events` |
|
|
59
|
+
| codex | `mcp__codex_apps__google_calendar._search_events` |
|
|
60
|
+
| gemini | `mcp_google-workspace_calendar.listEvents` |
|
|
61
|
+
|
|
62
|
+
The result is the connector's native shape; treat each entry as one
|
|
63
|
+
event with `summary`, `start`, `end`, `location` and continue with the
|
|
64
|
+
processing rules below.
|
|
65
|
+
|
|
66
|
+
`/api/calendar/events` returns 410 in delegated mode; do not call it.
|
|
67
|
+
On a connector error (auth lapsed, network failure), append
|
|
68
|
+
`- HH:MM Manual refresh: calendar connector error, schedule unchanged`
|
|
69
|
+
to `## Agent Log` and return without touching `## User Schedule`.
|
|
70
|
+
<!-- /mode:delegated-same:google_calendar -->
|
|
71
|
+
|
|
72
|
+
<!-- mode:delegated-cross:google_calendar -->
|
|
73
|
+
**Cross-backend delegated** — the Calendar connector lives on a
|
|
74
|
+
different backend than this session. Call the daemon's `/exec` task
|
|
75
|
+
endpoint with a natural-language intent; the daemon spawns the
|
|
76
|
+
delegated backend and lets it pick the right tool whichever connector
|
|
77
|
+
currently owns Calendar.
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
curl -s -X POST http://localhost:8321/api/integrations/google_calendar/exec \
|
|
81
|
+
-H 'Content-Type: application/json' \
|
|
82
|
+
-d '{
|
|
83
|
+
"task": "List every event on my primary calendar between <today 00:00 ISO> and <tomorrow 00:00 ISO>. Return up to 250 with id, title, start, end, attendees.",
|
|
84
|
+
"outputSchema": { "type": "object", "required": ["events"], "properties": { "events": { "type": "array", "items": { "type": "object", "required": ["id","title","start","end"] } } } },
|
|
85
|
+
"cacheable": true
|
|
86
|
+
}'
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- On `200`: the response payload exposes the schema-validated event
|
|
90
|
+
list under `.result.events` — continue with the processing rules
|
|
91
|
+
below.
|
|
92
|
+
- On `410` from `/api/calendar/events` (do NOT call it): would mean a
|
|
93
|
+
hallucinated direct call; never reach this branch.
|
|
94
|
+
- On `409 mode_mismatch` / `precondition`: state drifted during the
|
|
95
|
+
call. Append
|
|
96
|
+
`- HH:MM Manual refresh: calendar mode flipped mid-call, schedule unchanged`
|
|
97
|
+
and stop.
|
|
98
|
+
- On `503 delegated_proxy_busy`: queue full. Append
|
|
99
|
+
`- HH:MM Manual refresh: calendar proxy busy, schedule unchanged`
|
|
100
|
+
and stop (no retry — the dashboard user can re-click Regenerate).
|
|
101
|
+
- On `502 auth_error`: the delegated backend's connector is signed
|
|
102
|
+
out. Append
|
|
103
|
+
`- HH:MM Manual refresh: <backend> calendar connector signed out, schedule unchanged`
|
|
104
|
+
and stop.
|
|
105
|
+
|
|
106
|
+
Do NOT fall back to your own backend's native Calendar MCP tools —
|
|
107
|
+
they read a different Google account than the user's delegated one.
|
|
108
|
+
<!-- /mode:delegated-cross:google_calendar -->
|
|
109
|
+
|
|
110
|
+
<!-- mode:disabled:google_calendar -->
|
|
111
|
+
**Calendar disabled** — there is no live source to refresh from. Append
|
|
112
|
+
`- HH:MM Manual refresh: calendar disabled, schedule unchanged`
|
|
113
|
+
to `## Agent Log` and return without touching `## User Schedule`.
|
|
114
|
+
**Skip Steps 2 and 3.**
|
|
115
|
+
<!-- /mode:disabled:google_calendar -->
|
|
116
|
+
|
|
117
|
+
### Processing rules (apply after a successful fetch above)
|
|
118
|
+
|
|
119
|
+
- Today's local date comes from `<current_time>` (`local` attribute,
|
|
120
|
+
YYYY-MM-DD prefix). The configured timezone is `<current_time>`'s
|
|
121
|
+
`timezone` attribute — use it for every `HH:MM` you emit.
|
|
122
|
+
- Parse the event list, then:
|
|
123
|
+
1. **Filter to events that START today-local.** For timed events,
|
|
124
|
+
convert `start.dateTime` to the configured timezone and keep
|
|
125
|
+
only rows whose local date matches today. For all-day events,
|
|
126
|
+
keep only rows whose `start.date` equals today's YYYY-MM-DD.
|
|
127
|
+
(The query spans `[today 00:00, tomorrow 00:00)` in UTC, so
|
|
128
|
+
multi-day events that started earlier will appear — drop those.)
|
|
129
|
+
2. **Sort ascending by start time** (all-day events first, then
|
|
130
|
+
timed events in chronological order).
|
|
131
|
+
3. Render each row using these forms:
|
|
132
|
+
- Timed event: `- HH:MM–HH:MM <summary>` (append
|
|
133
|
+
` @ <location>` only when `location` is non-empty).
|
|
134
|
+
- All-day event: `- All day <summary>` (append ` @ <location>`
|
|
135
|
+
only when present). An event is all-day when `start.date` is
|
|
136
|
+
set and `start.dateTime` is absent.
|
|
137
|
+
4. If after filtering the list is empty, the body is the single line
|
|
138
|
+
`- No scheduled events today`.
|
|
139
|
+
|
|
140
|
+
### Step 2 — Replace the User Schedule section
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
curl -s -X PATCH http://localhost:8321/api/context/today \
|
|
144
|
+
-H 'Content-Type: application/json' \
|
|
145
|
+
-d '{"section": "user_schedule", "mode": "replace", "content": "<formatted lines>"}'
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
- Send ONLY the formatted event lines from Step 1. Do not include the
|
|
149
|
+
`## User Schedule` heading itself — the API manages section boundaries.
|
|
150
|
+
- If `409` Morning Routine lock: see retry-then-defer rule above.
|
|
151
|
+
|
|
152
|
+
### Step 3 — Log the refresh
|
|
153
|
+
|
|
154
|
+
Append one line to `## Agent Log` (skip this step entirely when Step 1
|
|
155
|
+
hit the error path or Step 2 gave up after 409 retries — see Ground
|
|
156
|
+
rules):
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
curl -s -X PATCH http://localhost:8321/api/context/today \
|
|
160
|
+
-H 'Content-Type: application/json' \
|
|
161
|
+
-d '{"section": "agent_log", "mode": "append", "content": "- HH:MM Manual refresh: user_schedule updated (<N> events)."}'
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Use the local `HH:MM` from `<current_time>` and the actual event count
|
|
165
|
+
`<N>` from Step 1.
|
|
166
|
+
|
|
167
|
+
### Output contract
|
|
168
|
+
|
|
169
|
+
Your final text is an internal log — the daemon does NOT forward it.
|
|
170
|
+
The dashboard watches `today.md` mtime to detect completion. Return a
|
|
171
|
+
one-line status like `user_schedule refreshed — N events` (or the
|
|
172
|
+
skip reason) and stop.
|