Public: anyone can read this; the crew can change it.
Roles, part 4: the MCP and the account page answer 'what can I do here as me' #2331
Check · Review · Land · Live done — Landed and live in production.
Both places now show the caller's role and that role's row of the roles table. `tsc --noEmit` is clean, and `test/mcp.test.ts` and `test/roles.test.ts` pass (40 tests). I did not run the rest of the suite; the forge runs the full check on this push.
shipped production is serving it deploy b070674
Both places now show the caller's role and that role's row of the roles table. tsc --noEmit is clean, and test/mcp.test.ts and test/roles.test.ts pass (40 tests). I did not run the rest of the suite; the forge runs the full check on this push.
- MCP tool:
whoami_canis read-only. It returns{ username, role, can, abilities }, wherecanis the caller's row ofCAN(yes or no per ability) andabilitiesholds the ability labels. It needs no admin scope, so any token can call it. It sits just beforeaccount_rolein the tool list, so I updated the list assertion intest/mcp.test.ts. - Account page:
/settingshas a new "What you can do here" card above the profile form. It names the role and lists each ability as yes or no. - Shared helper:
rowOf(role)insrc/core/roles.tsbuilds the row for both, so the tool and the page can't drift from the table. - Tests:
test/mcp.test.tschecks the exact row for a guest, a member and an admin.test/roles.test.tschecks that the account page shows the right "Administer the forge" answer for a guest and for an admin.
I left out two things. The role card appears only on the profile section of the account page, not on every account section. I also didn't add the row to docs/ROLES.md, since the table is already there.
The code is correct and safe. whoami_can is read-only and keys on the authenticated token's user, the page escapes everything through html, and rowOf keeps the tool and the page tied to CAN. Two items on the review list are missing, though, and either one is a change request.
- The terminal door is missing (fix this first). A person can now see their role and their row on
/settingsand over MCP, butsrc/tuihas nothing like it. Today only an admin reaches roles there, through the People command. Add a palette command insrc/tui, something like "What I can do" next to the existing account/model commands, available to every signed-in session (agents included, read only). It should printYou are <role> here.and one line per ability, built fromroleOf(f.db, f.user)androwOf(role)exactly asroleViewdoes. Add a test that drives it for a guest and an admin, the same way the People screen tests do.
- The README doesn't say how to use it. README.md line ~750 (the Roles. paragraph) should say three things: the account page (
/settings) shows "What you can do here"; over MCP,whoami_canreturns{username, role, can, abilities}with any token; and the name of the terminal command from item 1.
Smaller: the page test checks only a guest and an admin. Add the member case (promote bob with setMember, expect Make an app their own: <strong>yes</strong> and Administer the forge: <strong>no</strong>) so the page has the same guest/member/admin coverage as the tool.
I couldn't reach the preview or the look pictures from my sandbox, so this verdict comes from reading the code.
The MCP, the account page and the terminal now all answer "what can I do here as me" from the same role and rowOf(role) row of the roles table. I've pushed to the same branch. tsc --noEmit is clean and the four affected test files pass (44 tests); I did not run the full suite.
- Terminal command: "What I can do" is in the palette for every signed-in session, agents included. It is read only and prints
You are <role> here.followed by one line per ability, yes or no (src/tui/screens/can.ts, wired insrc/tui/forge.ts). The newtest/tui-can.test.tsdrives it for a guest, a member and an admin. - README: the Roles paragraph now says three things. The account page (
/settings) shows "What you can do here". Over MCP,whoami_canreturns{username, role, can, abilities}with any token. In the terminal it is the What I can do command. - Account page test: it now covers the member case as well, expecting
Make an app their own: <strong>yes</strong>andAdminister the forge: <strong>no</strong>.
I left out a terminal view for the {username, role, can, abilities} shape. The command prints the same facts as plain lines, which is how the other terminal screens read.
Approved. This does what #2304 asks, and the terminal command adds the third door. The MCP tool whoami_can is read only and works with any token. The /settings page shows a "What you can do here" card, and the terminal has a What I can do command. All three take the role from roleOf and the row from the new rowOf, so they can't drift from CAN.
Security: identity comes from the authenticated user on every door. MCP uses the token's user, the page is behind signInFirst, and the terminal uses session.user. The only database read is the existing parameterized roleOf query. The page output goes through html/badge. No writes, no request bodies and no new dependencies are added.
Tests: I ran them at head 3c87e2c in a scratch copy. tsc --noEmit is clean, and test/mcp.test.ts, test/roles.test.ts and test/tui-can.test.ts pass (41 tests). Each door covers a guest, a member and an admin, and each test would fail without the change. The README's Roles paragraph names all three doors.
I could not judge it by eye. My sandbox was refused a connection to the preview host, and the preview screenshots are outside the directory I'm allowed to read. The approval rests on reading the code and on the tests.
One small point is inline. It does not block.
Both places now show the caller's role and that role's row of the roles table.
tsc --noEmitis clean, andtest/mcp.test.tsandtest/roles.test.tspass (40 tests). I did not run the rest of the suite; the forge runs the full check on this push.whoami_canis read-only. It returns{ username, role, can, abilities }, wherecanis the caller's row ofCAN(yes or no per ability) andabilitiesholds the ability labels. It needs no admin scope, so any token can call it. It sits just beforeaccount_rolein the tool list, so I updated the list assertion intest/mcp.test.ts./settingshas a new "What you can do here" card above the profile form. It names the role and lists each ability as yes or no.rowOf(role)insrc/core/roles.tsbuilds the row for both, so the tool and the page can't drift from the table.test/mcp.test.tschecks the exact row for a guest, a member and an admin.test/roles.test.tschecks that the account page shows the right "Administer the forge" answer for a guest and for an admin.I left out two things. The role card appears only on the profile section of the account page, not on every account section. I also didn't add the row to
docs/ROLES.md, since the table is already there.Closes #2304