An open-source, faster Devin alternative
TypeScript
Work notes and docs: activity, owners, a session's items, trailers
Igor Zalutski via Computere86f2dbba8b2
diff --git a/TRIAGE_WEB_NOTES.md b/TRIAGE_WEB_NOTES.mdindex bf35c4d4..910af9b7 100644--- a/TRIAGE_WEB_NOTES.md+++ b/TRIAGE_WEB_NOTES.md@@ -80,3 +80,10 @@ skipped); Edit/Write "Edit <file>"/"Write <file>"; a plan "Review the plan";an MCP tool "Merge pull request · github". The Board, the session list andthe transcript's closed-ask line use the same words ("Wants to run psql").The session view's ask card reuses the same approval detail.++## Work items++Triage does not name the work item an ask belongs to. The session screen's+header does ("Work: 114 Title" chips, from `GET /work/sessions/{id}/items`),+and the thread name in Triage's header links there. Adding the chip to+Triage's header is one `<SessionWork id>` away if wanted.diff --git a/WORK_API_NOTES.md b/WORK_API_NOTES.mdindex dd80bdd7..b4762d50 100644--- a/WORK_API_NOTES.md+++ b/WORK_API_NOTES.md@@ -21,7 +21,16 @@ Build step 3, the service side. This file covers the shapes and headers, how the- `GET /work/items/{n}/history[?cursor]` returns `{ revisions: [{ sha, url, at, authorName, summary, sessionId: string | null }], nextCursor }`.- Newest first, 30 per page.- The cursor is a keyset on `(at, sha)`.+- `GET /work/sessions/{id}/items` returns `{ items: Item[] }`: the items whose commits name the session in a `Session:` trailer, by its `cs_` id or its runner key, numbered order, at most 50.+ - The session must be one the caller may see (the Computer object's `work.refs` op answers its id and key). Otherwise, or for an id that is not `[A-Za-z0-9_-]{1,128}`, it is 404 `session_not_found`.+ - It is for the session screen's "Work:" chips. Scope `work:read`; the edge allows `GET` on it.- In `Item`:+ - `owner` is `{ email, name, id, source: "declared" | "derived" } | null`.+ - `declared` is the doc's `owner:` frontmatter.+ - `derived` is the author of the item's latest commit that was not a bulk edit, else of its latest commit of any kind, else null. The name drops a trailing " via Computer"; `name` and `id` resolve the email to a member as for the author, and the commit's name is the fallback.+ - `mine` holds for a derived owner too.+ - `lastActivityAt` is the item's latest commit that touched at most 5 item files (`BULK_ITEMS`). A commit touching more is a bulk edit: it moves `updatedAt` only. Null when the index has read no such commit (also before the walk dates the item).+ - `active` is `lastActivityAt` within 14 days (`RECENT_DAYS`), or `attention` is set (a linked session the caller may see is running or waiting). The index computes the first part (`recent`), the Worker composes the second.- `updatedAt`, `createdAt`, `closedAt` and `closedBy` are null until the walk (below) has read the commit that settles them. They are never a placeholder date.- A move to `done/` that has not been dated yet leaves `closedAt` and `closedBy` null. They are not taken from the newest commit.- Errors use the usual envelope: `{ error: { code, message, requestId, retryable, ... } }`.@@ -30,7 +39,8 @@ Build step 3, the service side. This file covers the shapes and headers, how the## Headers- `ETag` on the open list.- - It is `"<head|none>-<sha256/16 of [index version, sessions stamp, caller member, caller email]>"`.+ - It is `"<head|none>-<sha256/16 of [index version, recent open items, sessions stamp, caller member, caller email]>"`.+ - The count of recent open items moves the tag when an item ages out of `active` with no commit and no session write.- The index version moves on every write that changes output, including pull request state.- The sessions stamp is a counter in the Computer object (`work_stamp`). AFTER INSERT/UPDATE/DELETE triggers on `sessions` and `people` move it, so every write moves it, including the ones that leave `updated_at` alone (for example an `owner_name` change). Triggers were chosen so that no write path can forget to bump it.- The tag is checked before the list is read or composed. An unchanged poll costs two stamp calls (the index and the Computer object) and no SQL beyond them.@@ -145,7 +155,8 @@ The walk fills them, with one `commits?path=work` and one `commits?path=done` li6. A listing stops at the first commit already listed for that folder, or at a short page.7. Each detailed commit is applied in its own transaction:- revisions and links;- - `updatedAt` is the latest commit;+ - `updatedAt` is the latest commit, with its author;+ - `lastActivityAt` and the derived owner are the latest commit that touched at most 5 item files, with its author;- `createdAt` and the author come from the add, or from a rename from a non-item path;- `closedAt` and `closedBy` come from the latest move into `done/`.@@ -180,10 +191,24 @@ Measured with the fake GitHub in `work-index.test.ts`. The fake enforces the rea| Advance over 500 commits (400 non-item files, 100 item edits) | 115: 1 ref + 1 compare + 2 trees (root, `work/`) + 100 blobs + 1 listing page + 10 details. No rebuild. || The walk finishing that range | 91, over later alarms. || Advance over one commit | 3: ref + compare + one blob per changed item. |+| Walk of 150 items over 300 one-item commits | 306: 5 listing pages (4 of `work/`, 1 of `done/`) + 301 details. Activity and derived owners add nothing. || Board poll, unchanged | At most 1 ref per 10 s window, plus the two stamp calls (no GitHub). A 304. || Item page | 0, or 1 blob the first time a closed item is opened. || History once walked | 0. |+## Activity and owners++- Both come from the per-commit file lists the walk and the advance already read, so they cost no GitHub call. The first build stays 154 calls for 150 items; a walk of a few hundred commits is about one listing page per 100 commits per folder plus one detail per commit (306 for 300), spread over alarm ticks by the quota guard.+- Until the walk has dated an item, its `lastActivityAt` and derived owner are null, and it is dormant unless a session is at work. On a first build this lasts until the walk is through.+- **Decision: the walk is not capped by age.** It also gives history, the author, `createdAt` and `closedAt`, and a cap would leave the derived owner to bulk commits only. Activity older than 14 days is dormant whatever its depth. GraphQL history was considered and not used: it has no file lists (bulk edits cannot be told apart) and would be a second code path.+- `SCHEMA_VERSION` is 3: the tables are dropped and rebuilt once on deploy (new item columns `updated_name`, `updated_email`, `activity_at`, `activity_name`, `activity_email`).++## Session: trailers (what a link needs)++- The knowledge repository's `prepare-commit-msg` hook (`computer/hooks/knowledge/prepare-commit-msg`) adds `Session: $SP_SESSION_ID`. `SP_SESSION_ID` is the session's `cs_` id, or its runner key when it has none yet (`runner/session-secrets.ts`). The hook is installed by `syncKnowledgeHooks` (`computer/src/workspaces/knowledge-hooks.ts`) at housekeeping and on workspace setup; worktrees share it.+- Gaps, read from the code and not run: a commit through an editor (no `-m`/`-F`) gets no trailer; Codex has `SP_SESSION_ID` only through `BASH_ENV`, so only in bash; a repository cloned on demand (`checkoutRepos`) has no hook until the next housekeeping.+- On a dev stack a link appears when: the stack's computers run a bundle of this branch (they pull `calvin-latest.bundle` every 5 minutes); the repository is set with `PUT /work/repository` and the index is bound; housekeeping has installed the hook; the host is at v4; the commit is made with `-m`/`-F` in the session's worktree and pushed; the index has walked it. A Slack session's links are visible only to its owner.+## Limitations- The walk stops a folder's listing at the first commit it has already listed. Commits that a merge brings in and that are older than an already-listed commit can be missed. The knowledge repository is mostly linear, and a rebuild re-lists everything.diff --git a/WORK_WEB_NOTES.md b/WORK_WEB_NOTES.mdindex 199cfb6c..9d620a67 100644--- a/WORK_WEB_NOTES.md+++ b/WORK_WEB_NOTES.md@@ -36,9 +36,12 @@ add fields without breaking the screens.- It is fetched once the repository is set, with "Load more" following `nextCursor`.- `GET /work/items/{n}` returns `{item, body}`. It is polled every 15 seconds.- `GET /work/items/{n}/history[?cursor=]` returns `{revisions, nextCursor}`. It is fetched only while the History tab is open.+- `GET /work/sessions/{id}/items` returns `{items}`: the items whose commits name the session. The session screen's header reads it once a minute at most (`SessionWork.tsx`, no retry) and shows nothing on any error.- `Item` and `Revision` follow the contract field for field.- Item sessions are `{id, title, ownerName, status}`; `status` is required, one of `starting | running | waiting | idle | suspended`.- - `updatedAt` may be null while not known yet. Such an item sorts last within its group, is never stale, and shows no time (card and item header).+ - `owner` is `{email, name, id, source: 'declared' | 'derived'}`. `derived` comes from recent commits (the server's choice); `mine` is the server's for both.+ - `lastActivityAt` (the item's own last change, bulk edits left out) and `active` are the server's. The web compares no dates for them.+ - `updatedAt` may be null while not known yet. Such an item sorts last within its group and shows no time (card and item header).- `closedAt` and `closedBy` may be null on a closed item. The card and header then say just "Closed" with no time (or the `updatedAt` time when only that is known), and the item shows in the Closed column only with "Show older".- Any 404 from a `/work` route reads as "not available yet" (section 4), except a 404 with code `item_not_found` on the item page: that reads "No item 123", with a link back to the board.@@ -61,9 +64,13 @@ The web renders the server's `stage`, `readyToClose`, `attention`, `mine`, `warn- In progress is `stage=open` with `!readyToClose`.- Ready to close is `stage=open` with `readyToClose`.- Closed is `stage=closed`.- - Within a column, items with `attention.state = needs_you` come first, then `updatedAt` newest first.+ - Within a column, items with `attention.state = needs_you` come first, then `lastActivityAt` (else `updatedAt`) newest first.- Attention: only `needs_you` is coloured (amber). Waiting reads "waiting on X · 3h" and working reads "agent working"; both are grey.-- Stale: an open card whose `updatedAt` is 14 or more days old is shaded, and "no change in N days" replaces its time. The threshold is a client constant.+- Dormant: open items with `active: false`. Each open lane (In progress, Ready to close) shows its active items and ends with a quiet "Dormant (N)" toggle, collapsed by default; the lane's count is the active count. Open lanes are kept in the address (`?dormant=progress,ready`). It is a view, not a stage. The toggle's hover text says what dormant means: "No change of their own in two weeks and no session at work". The client has no threshold; the old stale constant is gone.+- Time on an open card: `lastActivityAt`, else `updatedAt`, so a bulk retag does not make a dormant item look fresh.+- Owner: avatar and name on the card. A derived owner is muted, with a dashed avatar ring and the hover text "Name · From recent commits"; the item page says "(from recent commits)". No owner shows nothing.+- Sessions: the card's activity line links each linked session (a status dot, hover "title · owner · status") to `/computer/sessions/{id}`; Details on the item page already did.+- Session screen: the header shows "Work: 114 Title" chips (two at most, then "+n") linking to the items the session's commits name.- Closed column: by default it shows items with `closedAt` in the last 7 days. "Show older" (kept in the address as `?older=1`) shows every fetched closed item.- Address state: the tab (`?tab=everyone`; Mine is the default), the text filter (`?q=`) and the tag filter (`?tag=`) all live in the address. Tags on cards set the tag filter.- Mine empty: shown when Mine has nothing, Everyone has something and no filter is set. It links to Everyone.@@ -95,6 +102,7 @@ The web renders the server's `stage`, `readyToClose`, `attention`, `mine`, `warn- `problem` sends `access_denied` with a `problemMessage`; `&problem=<code>` sends another code, without a message.- `/repositories` lists eight repositories under `acme` and two under `acme-labs`, the preview's two installations. `?work=none` shows the combobox alone. The preview's organization (`api/mock.ts`) has four members and two invitations, so the Members section has something to show.- Item 31 has an unknown `updatedAt`; closed item 8 has no `closedAt` or `closedBy`.+- Owners are mixed: declared, derived (muted) and none. Items 3, 5, 6, 7, 10 and 11 are dormant; 5 was touched yesterday by a bulk edit only, 11 has an idle session. `/sessions/{id}/items` answers from the mock items' sessions, so the session screens show Work chips.- An unknown item number answers 404 `item_not_found`.## Visual pass@@ -133,8 +141,8 @@ regularity of Linear's board and issue page, not its features.- Colour: only "needs you" is coloured (amber). Doc problems and unpublishedchanges are grey icons on the card (words and colour on the item page).Pull request dots keep their state colours, as the spec asks for state.-- Stale: the card loses its raised surface and sits flat on the lane with a- dashed border, its title dimmed; the age says "no change in N days".+- Dormant (when unfolded): the card loses its raised surface and sits flat on+ the lane with a dashed border, its title dimmed.- Item page: a neutral stage pill, then one metadata line with dotseparators (a dot that wraps to the start of a line is clipped away). Only"needs you" and the doc problem keep their colour there; "unpublisheddiff --git a/docs/api/overview.mdx b/docs/api/overview.mdxindex d3693136..af7adaec 100644--- a/docs/api/overview.mdx+++ b/docs/api/overview.mdx@@ -53,7 +53,7 @@ A credential without a scope list has every scope.| `sessions:write` | `turns.send`, `turns.cancel`, `sessions.update`, `sessions.interrupt`, `sessions.compact`, `sessions.suspend`, `sessions.resume`, setting a session aside, file upload || `asks:answer` | `asks.answer`, `asks.dismiss` || `terminals` | `terminals.open`, `terminals.resize`, `terminals.eof`, `terminals.close` |-| `work:read` | `GET /work/repository`, `GET /work/repositories`, `GET /work/items`, `GET /work/items/{number}`, `GET /work/items/{number}/history` |+| `work:read` | `GET /work/repository`, `GET /work/repositories`, `GET /work/items`, `GET /work/items/{number}`, `GET /work/items/{number}/history`, `GET /work/sessions/{id}/items` || `work:write` | `PUT /work/repository` |`work:read` and `work:write` are granted only to a key that names them, never by a missing scope list or `*`. A session's own key is refused on `PUT /work/repository`.