Setup pi bot user #1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://agenticengineer.com/the-only-claude-code-competitor/pi-logo.webp
/pi hello are you there? just say HI
HI 👋
View action run | Model: zai/glm-5.2 (thinking: xhigh) | Time: 16s | Tokens: 3.1K | Pi SDK v0.80.3 | Action v2.25.0-develop (develop @ 0e171ae)
/pi how should I setup the pi user to be used as bot in Forgejo? create a report
I have all the context I need. Let me create a comprehensive report and commit it to the repo.I've written the report to
docs/setup-pi-bot.md(committed tomainasd501721). Here's the summary.How to make
piyour Forgejo bot identityThe key idea: in Forgejo, the token determines who acts. Today your workflow runs with the auto-injected
FORGEJO_TOKEN, so every reply/commit/PR is authored by the system accountforgejo-actions(see the first reply above). To post as a dedicatedpiuser, you create that user and feed a PAT from it into the workflow.Steps
piuser (Site Admin → Users → New Account). Its username + avatar become the bot's public face — uploadpi-logo.webp, add a bio. Make it a normal/restricted user.pias a Collaborator (Write) on each repo, or for your personalalex/*forge, an owner-level role.pi(Settings → Applications → Access Tokens) with minimal scopes:issue:write,pull_request:write,repository:write, plus reads. Set a 90-day expiry.PI_TOKEN— at the owner level so allalex/*repos inherit it. (Tokens go insecrets, nevervars— secrets are masked, variables are not.)/pi who are you?; the reply should now show as@piwith the logo.Watch-outs
main/branches are protected, allowpi(or token pushes) to bypass, or commits/merges get blocked./picurrently triggers for any comment — consider restricting who can invoke it.Full details (background, scope table, alternatives, security checklist) are in
docs/setup-pi-bot.md. Want me to apply the Step 5 workflow edit as a PR?View action run | Model: zai/glm-5.2 (thinking: xhigh) | Time: 2m 23s | Tokens: 38.8K | Pi SDK v0.80.3 | Action v2.25.0-develop (develop @ 0e171ae)
/pi update every Pi workflow in this forge to restrict trigger to admins, create PRs accordingly
I have the full context. There's one Pi workflow (
.forgejo/workflows/pi.yml) that currently triggers on/pifor any commenter. The task is to restrict it to admins. Let me make the change and open a PR.The change is applied. Now let me create a branch, commit, push, and open a PR. Since this is Forgejo, I'll use the Forgejo API directly with the available token.PR created. Let me verify it looks correct.Done.This forge has a single Pi workflow —
.forgejo/workflows/pi.yml— so one PR covers it.PR #2 → #2 — ci: restrict Pi workflow trigger to repo admins
What changed
Added an
author_associationguard to thepi-agentjob'sifso/pionly fires for repo admins:OWNER→ the repo owner (covers personal forges like this one, wherealexis owner).MEMBER→ org members with admin rights (covers org-owned repos).Non-admin commenters (
CONTRIBUTOR,NONE,FIRST_TIME_CONTRIBUTOR, …) are now silently skipped by the job. This closes the gap the bot-setup report flagged — previously any registered user could invoke the agent and the LLM spend / repo write that comes with it. This matches how I (the bot) was able to run just now: your comment isOWNER-associated, so it still triggers.If you'd prefer a tighter or looser policy (e.g.
OWNER-only for this personal forge, or also allowingCOLLABORATOR), say the word and I'll adjust.View action run | Model: zai/glm-5.2 (thinking: xhigh) | Time: 3m 17s | Tokens: 93.9K | Pi SDK v0.80.3 | Action v2.25.0-develop (develop @ 0e171ae)
/pi can we have a single reusable Pi workflow and just refer to it from other workflows in this forge?
The Forgejo version is 15.0.3, so reusable workflows (
workflow_call) are fully supported. Let me implement this — refactoringpi.ymlinto a reusable workflow and adding docs + a drop-in wrapper for other repos.Everything looks correct. Let me create the PR with these changes.The PR tool hit a 404 (likely a Forgejo API path difference). Let me do it directly via git + the Forgejo API.Branch pushed. Now let me open the PR via the Forgejo API.Yes — that's exactly the right instinct, and Forgejo 15 supports it via standard reusable workflows. Done in PR #3 → #3.Short answer
You can't have zero config per repo (Forgejo dispatches
issue_commentper repo, so one workflow can't auto-run across all of them), but you can have one source of truth that every repo delegates to with a 4-line wrapper. That's strictly better than copying the full file.What changed
.forgejo/workflows/pi.yml→ now a reusable workflow: added theworkflow_calltrigger alongside the existingissue_commentone. Soalex/.profilekeeps firing directly (it's its own consumer, no wrapper needed), and every other repo can call it.docs/examples/pi.yml→ ready-to-copy drop-in wrapper.docs/reusable-pi-workflow.md→ full guide.How another repo enables Pi
Drop this at
.forgejo/workflows/pi.ymlin anyalex/*repo:It works because the comment event propagates into the called workflow (so the
ifguard andgithub.event.commentstill resolve),actions/checkoutchecks out that repo (github.repository= the caller), and owner-levelsecrets/vars(LLM_API_KEY,MODEL, …) are inherited viasecrets: inherit.Why this is the right move for #1
This is where reuse and the
pibot identity compound: whenPI_TOKENis set up (perdocs/setup-pi-bot.md), flippinggithub_tokenfrom${{ env.FORGEJO_TOKEN }}to${{ secrets.PI_TOKEN }}in this one file makes every consuming repo post as@pi— instead of editing N repos. I left the token untouched in this PR so nothing breaks; it's a one-line follow-up once the PAT exists. PR #2 (admin-only trigger) is independent and merges cleanly against this.View action run | Model: zai/glm-5.2 (thinking: xhigh) | Time: 6m | Tokens: 169.3K | Pi SDK v0.80.3 | Action v2.25.0-develop (develop @ 0e171ae)
/pi what's missing from this ticket?
Looking at the ticket against the plan in
docs/setup-pi-bot.md, the supporting work is in place but the core deliverable of the ticket isn't actually done — the bot still isn'tpi. Here's what's missing:1. The identity switch itself (the whole point)
.forgejo/workflows/pi.ymlstill uses the auto token:That's the one-line change (report Step 5) that makes the agent act as
pi. It was explicitly deferred in PR #3, so every reply is still authored by@forgejo-actions— including the one you're reading right now. Until that flips to${{ secrets.PI_TOKEN }}, the bot user is not "set up" in any observable sense.2. The manual prerequisites (Steps 1–4) — no evidence they're done
piaccount confirmed to exist (logopi-logo.webpwas dropped in comment 1 but there's no sign it's uploaded to a user).PI_TOKENActions secret (owner-level) — proven by point 1: if it existed and were wired, replies would already show@pi.These are admin-side and can't be done from code, but the ticket should track them so "done" is verifiable.
3. No acceptance criteria / definition of done
The ticket body is just the logo image — there's no checklist. The report's own Security checklist is entirely unchecked, and there's nothing stating what "setup pi bot user" means as a gate (e.g. "
/pi who are you?replies as @pi; commits pushed by agent are authored by pi").4. Scope note
The thread has produced two real PRs (#2 admin-only trigger, #3 reusable workflow) — both useful, but arguably scope creep relative to the ticket's title. They should probably live as their own issues so #1 can close cleanly on the identity setup alone.
TL;DR: the report, admin-gating, and reusable workflow are done; what's missing is the
piidentity actually existing and being used — thePI_TOKENsecret + the one-linegithub_tokenswap. Want me to open a PR making thepi.ymlchange (Step 5) so it's ready the moment you create thepiuser +PI_TOKENsecret?View action run | Model: zai/glm-5.2 (thinking: xhigh) | Time: 1m 24s | Tokens: 26.1K | Pi SDK v0.80.3 | Action v2.25.0-develop (develop @ 0e171ae)