Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open-ended work. The default provider and model come from Settings → Providers
| Away spans | `away/`, `web/src/away.ts`, `web/src/components/AwayEditor.tsx`, `mobile/src/features/overview/AwaySheet.tsx` | Trips and days off in `data/away.json` (`AWAY_FILE`): inclusive local day keys, edited by the owner from the Overview's schedule card (`/api/away`). Every prompt's date block marks away days in its 14-day table and names the current and coming spans, capped at five, and always says to propose a trip found in email (`away/grounding.mjs`); the calendar draws them as a band; a queued notification whose category's `away` column is `'hold'` waits one night at a time (`heldBy: 'away'`) and goes out the first morning the owner is back, older digest copies dropped and nothing distinct lost (`away/hold.mjs` through `gate.addHold`, `notify/categories.mjs`). Agents get `totem_away_list` and `totem_away_propose` (`away__*` in the gateway): propose stages an `away` inbox item once per set of dates, only the dashboard accepts it, and there is no write tool. Agents never edit `data/away.json`; the store re-reads it when it changes on disk and drops rows that fail validation. `docs/away.md`. |
| Voice journal | `journal/`, `web/src/journal/` | Record in the browser, transcribe on the box with whisper.cpp, digest into the notes repo after a grace period. `docs/journal.md`. |
| Notifications | `notify/`, `web/public/sw.js` | Web Push (RFC 8291/8292 on `node:crypto`) and APNs for the native iPhone app (`notify/apns.mjs`, `APNS_*`; a chat's notification is taken back off the phone by a silent push once the chat is read anywhere, `notifier.dismiss`), a due-queue drained on the job tick, digests, feed scan, quota nudges. On an away day a queued notification whose category's `away` column is `'hold'` waits until the owner is back (`createAwayHold` in `away/hold.mjs`, registered through `gate.addHold`; a hold's `tag` stays on the entry as `heldBy`, which skips the missed-delivery cutoff and is claimed after everything never held; a repeat is suppressed when first held, by `admit(item, { reserve: false })`, not after the earlier copy's window runs out). Every push passes the dedupe gate in `notifier.deliver` (`notify/dedupe.mjs`): a key already sent inside its window (a quota fact's key is its reset window, persisted across restarts; keyless repeats only in categories with `textDedupe`) or a story already told (only items carrying `story`: canonical link, or headlines with the same lead model and version, no event kind the earlier lacks, shared details and real word overlap, within 48 h; an optional background model check for close calls, Claude or Codex only, that fails open) is counted on the first notification instead of pushed, and logged. Sends are reserved, then committed only if they reached the bell or a phone. Settings → Notifications › Duplicates; `gate.addHold(fn)` keeps a queued one waiting. Habits get no completion nudges (no "streak ends tonight"): they can be logged for past days, so the notifier drops any still queued (`isRetiredNudge`). `docs/notifications.md`. |
| Totems | `totems/`, the "Totems" block in `bridge.mjs`, `web/src/components/TotemsView.tsx`, `web/src/totems/` | Off the nav rail: reached from the chats panel's Totems switch ("All totems") or a totem chat's gear. A list like the chats list: a row opens the totem's chat (its runs are posted there), the gear its settings; the totem's chat header has a play button that runs it now. The chats panel and phone drawer switch between Chats and Totems (group chats, then totems by last run, with running/unread/failed marks; `web/src/chat/totemNav.ts`). Any chat can bring totems in: `totems__list`/`totems__ask`/`totems__wait`/`totems__invite` run a totem on its own model with its memory and tools, and its answer shows under its name (`web/src/chat/totemReply.ts`); a chat with `members` is a group chat its agent hosts. On by default (`totemsInChat`, Settings → Chat). Standing agents over the job store: every job is a totem (no second scheduler). A totem's runs keep the standard job limits unless its Full access switch is on (`access: 'full'`: bypassPermissions / danger-full-access, since nothing can approve a command mid-run), and write their memory and their chat's outputs folder. Agent totems keep `data/totems/<id>/memory.md` (pasted into each run and ask, a fresh session that needs its state; only named in the totem's chat, which reads it on demand), end runs with `NOTIFY:`/`QUIET`, post runs to their chat `totem-<id>`, and get cheapest-first model recommendations from the builder or any model from the chat picker (`modelsOnly`). The builder asks scoping questions in a chat beside the draft and revises it on each reply; an unfinished design is a draft (`totems/drafts.mjs`, `data/totem-drafts/`). A totem can wake on a watch (git branch or web page) instead of a schedule; the built-in "Deploy Totem" pulls, rebuilds and restarts the bridge when main moves. Any chat can propose a change (Accept card). Replaced Studio. `docs/totems.md`. |
| Totems | `totems/`, the "Totems" block in `bridge.mjs`, `web/src/components/TotemsView.tsx`, `web/src/totems/` | Off the nav rail: reached from the chats panel's Totems switch ("All totems") or a totem chat's gear. Laid out like a project's page: a composer that hands a description to the builder, then flush rows (drafts, group chats, totems, and a folded shelf of the built-ins that are off): a row opens the totem's chat (its runs are posted there), the gear its page, whose settings are drawn with the Settings dialog's sections and rows (`web/src/totems/fields.tsx`, shared with the builder's draft); the totem's chat header has a play button that runs it now. The chats panel and phone drawer switch between Chats and Totems (group chats, then totems by last run, with running/unread/failed marks; `web/src/chat/totemNav.ts`). Any chat can bring totems in: `totems__list`/`totems__ask`/`totems__wait`/`totems__invite` run a totem on its own model with its memory and tools, and its answer shows under its name (`web/src/chat/totemReply.ts`); a chat with `members` is a group chat its agent hosts. On by default (`totemsInChat`, Settings → Chat). Standing agents over the job store: every job is a totem (no second scheduler). A totem's runs keep the standard job limits unless its Full access switch is on (`access: 'full'`: bypassPermissions / danger-full-access, since nothing can approve a command mid-run), and write their memory and their chat's outputs folder. Agent totems keep `data/totems/<id>/memory.md` (pasted into each run and ask, a fresh session that needs its state; only named in the totem's chat, which reads it on demand), end runs with `NOTIFY:`/`QUIET`, post runs to their chat `totem-<id>`, and get cheapest-first model recommendations from the builder or any model from the chat picker (`modelsOnly`). The builder asks scoping questions in a chat beside the draft and revises it on each reply; an unfinished design is a draft (`totems/drafts.mjs`, `data/totem-drafts/`). A totem can wake on a watch (git branch or web page) instead of a schedule; the built-in "Deploy Totem" pulls, rebuilds and restarts the bridge when main moves. Any chat can propose a change (Accept card). Replaced Studio. `docs/totems.md`. |
| Jobs | `jobs/` | Timezone-aware schedules (`daily`, `weekly`, `interval`, `window`), watch triggers over one or more git branches or pages, checked without AI (`jobs/triggers.mjs`), and `data/jobs.json`. One 30-second tick in `bridge.mjs` runs jobs, checks watches and drains notifications. A job id Totem stopped shipping goes in the store's `retiredIds` and is dropped on read. `docs/jobs.md`. |
| Skills | `skills/` | Every prompt as an editable `SKILL.md` with `{{variables}}`. Generic seeds in `skills/seeds/` are copied into `data/skills/` once. Chat cites a skill with `/name` anywhere in a message; the owner's Claude Code/Codex/Cursor skills are found read-only by `skills/agent-skills.mjs` and cited the same way. `docs/skills.md`. The `change-totem` seed is the steps for changing Totem itself from a chat; the guardrails are in code (next row), not in the skill. |
| Changing Totem from a chat | `dev/change.mjs`, `change_start`/`change_finish` on each chat run's `/agent-mcp` (`changeTools` in `bridge.mjs`), `web/src/chat/ChangeCard.tsx` | "Build me a page for X" ends as a pull request card, never as edits to the checkout Totem runs from. Offered only to Full-access chat runs. `change_start` fetches `origin/main` into `refs/totem-change/base` (never moving the live `origin/main`) and makes a worktree under `CHANGE_WORKTREES_DIR` (default `~/.totem-changes`; the path is checked before anything is created, and refused inside or around the live checkout or over `AGENT_CWD`/cwd), linking `node_modules`. `change_finish` first checks every field of its record (`data/changes.json`, denied to Claude's file tools) against git and GitHub, then stages the worktree into a tree and checks it as one diff against the base, reading git's output in full (anything that would not fit is refused; at most 500 files, 5 MB of diff; diffs with `--no-ext-diff --no-textconv` and fixed prefixes): paths are case-folded and must be ASCII (macOS deploys), and it refuses data/env/secrets/`.git`/`node_modules`, package-manager and git config files, symlinks and submodules, case collisions, protected files (`auth/`, `logs/approval*`, `.github/`, the rule-enforcing files in `PROTECTED_FILES`, the flow itself), `bridge.mjs` lines in `GUARDED_LINE`, changed package `scripts`, `.gitignore` lines about `node_modules`, and any secret from Totem's credential files (`data/*-tokens.json`, `auth.json`, `ai-settings.json`, `integrations.json`, the MCP manifest's env, `BRIDGE_SECRET`) or a known token shape anywhere in a changed file's whole content (a tripwire for accidents, not a boundary). It then makes one fresh commit of that tree on the last push, runs `npm test` (retried once) and the web build with a throwaway `HOME` and no git config or tokens, refuses if they moved HEAD or wrote tracked files or the live checkout got dirty (by content hash), and pushes exactly that SHA to `totem-change/*`. Stop or a timeout kills the checks' whole process tree. It opens the PR with `gh`, saves it at once, and posts a `change-pr` card whose CI state is a snapshot at push. A merged or closed PR starts a fresh worktree, and so does a record that no longer checks out (the remote branch moved); every git call has filters and attribute files switched off, and `.git/info/attributes` is refused; `cleanup()` (boot, then every 6 h) removes those and ones abandoned 14 days. No merge path anywhere. Off unless the owner sets `CHANGE_FLOW_ENABLED=true` (`changeFlowEnabled`), and only when Totem runs from a git checkout. `docs/change-totem.md`. |
Expand Down
38 changes: 31 additions & 7 deletions docs/totems.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ errors).
|---|---|
| Prompts, parsers, cost tiers (pure, tested) | `totems/core.mjs`, `totems/core.test.mjs` |
| Engine and routes | `bridge.mjs`, the "Totems" block beside the job engine |
| UI | `web/src/components/TotemsView.tsx` (list, group picker, builder, settings), `totems.css`; `web/src/totems/shared.tsx`; a totem's answer in a chat `web/src/chat/totemReply.ts` + `Message.tsx`; proposal card `web/src/chat/TotemProposal.tsx`. iPhone: `mobile/src/features/totems/` (`TotemGroupSheet.tsx` picks a group's totems) |
| UI | `web/src/components/TotemsView.tsx` (the list and group picker), `web/src/totems/Builder.tsx`, `web/src/totems/Detail.tsx` (a totem's page), `web/src/totems/fields.tsx` (the settings sections both share), `totems.css`; `web/src/totems/shared.tsx`; a totem's answer in a chat `web/src/chat/totemReply.ts` + `Message.tsx`; proposal card `web/src/chat/TotemProposal.tsx`. iPhone: `mobile/src/features/totems/` (`TotemGroupSheet.tsx` picks a group's totems) |
| Memory | `data/totems/<jobId>/memory.md` (`TOTEMS_DIR`) |
| Chat | thread `totem-<jobId>`, carrying `totemId`; kept out of Recents. Group chats are regular chats with `members` (job ids) |

Expand Down Expand Up @@ -128,7 +128,8 @@ are dropped, and if none is left the schedule applies.

**The builder is a conversation.** Its reply carries a `reply` sentence and up to
three `questions` about scope it would otherwise guess (a host, a path, a
threshold). The builder page shows them in a chat panel beside the draft; each
threshold). The builder page shows them in a chat card beside the draft (above it
on a narrow window); each
message he sends is one more builder turn (`POST /api/totems/build {draftId,
draft, message}`) that gets the conversation, the draft as it stands (his own
edits included, so a rename or rewritten instructions survive) and his message,
Expand All @@ -152,11 +153,34 @@ settings offer the same picker.

## The list

The tab reads like the chats list. Each totem is a row with the newest thing in
its chat (a run's report, or the last thing said), how long ago, an unread dot,
and its status line; clicking the row opens that chat, so reading what its runs
found is one click. The switch pauses it; the gear opens its settings, memory and
runs (`/totems?totem=<id>`), which the gear in the totem's chat header also opens.
The page reads like a project's page, after T3 Code: a title, a composer to
describe a new totem (Enter hands the words to the builder, which starts designing
at once; three example chips fill it), then sections of flush rows: Drafts, Group
chats (with "New group chat"), Totems (his own and every built-in that is on, the
ones that are on first, then whichever spoke last), and a folded "More built in"
shelf for the built-ins that are off (`isBuiltIn`: a runner, a skill or a seeded
job), with deleted built-ins to restore at its end (open or folded is kept per
device, `totem.totems.builtInOpen`). Pausing a built-in moves it there, so the
toast says where it went (`setTotemEnabled`). Each totem's row has the newest
thing in its chat (a run's report, or the last thing said), how long ago, an
unread dot, and a short status beside its name: its schedule or "Watching", and a
dot only for trouble (last run failed, can't check), a pause or a run in progress
(`totemBrief` in `web/src/totems/shared.tsx`). Clicking the row opens that chat,
so reading what its runs found is one click. On hover the row shows a gear for its
page and a "…" menu: Open chat, Run now (the row says "Running now" until it ends),
Pause/Turn on, and its page; on a touch screen only the "…" shows, always.

A totem's page (`/totems?totem=<id>`, also the gear in its chat header) has a
header (icon, name, kind, status; Open chat, Run now and an On switch), a red note
when the last run failed, and Settings / Memory / Runs tabs. Settings is drawn with
the Settings dialog's sections and rows (`components/settings/ui.tsx`;
`settings.css` scopes them to `.tm-view` too): Totem (name, description, icon from
the chat icon set), Instructions, When it runs, Model, Behaviour (notify, browser,
full access) and Delete. Name, description, icon, schedule, model and switches
save at once; instructions, memory and a watch wait for Save, whose bar appears
once there is something to save. The builder's draft uses the same sections
(`web/src/totems/fields.tsx`) with a Create bar under them (on a phone, Create
also sits under the name).
Beside that gear, a play button runs the totem now (`POST /api/jobs/run`, the same
manual run as its settings page) instead of waiting for its schedule or watch; it spins
until the run ends and its report lands in the chat (`TotemRunButton` in
Expand Down
Loading
Loading