Skip to content

Let loopway threads sessions act as a GitHub bot user - #51

Merged
mcwhittemore merged 4 commits into
mainfrom
worktree-issue-31-bot-identity
Oct 8, 2026
Merged

mcwhittemore merged 4 commits into
mainfrom
worktree-issue-31-bot-identity

Conversation

@mcwhittemore

@mcwhittemore mcwhittemore commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Lets loopway threads sessions comment, open PRs, push and commit as a GitHub bot user instead of as whoever runs the dispatcher. This is the config-only first step agreed in #31.

What changed

  • Config. ~/.loopway/config.json takes an optional github: { token, name, email }. LOOPWAY_GITHUB_TOKEN / LOOPWAY_GITHUB_NAME / LOOPWAY_GITHUB_EMAIL override it. Set all three or none; a partial setup fails at startup with a clear error.
  • Session environment (packages/cli/src/threads/github.ts). When a bot is configured, every session gets:
    • GH_TOKEN and GITHUB_TOKEN, so gh comments and opens PRs as the bot, and other tools that read GITHUB_TOKEN don't get a token the user exported.
    • Git config passed as GIT_CONFIG_KEY_n/VALUE_n, so nothing is written to the user's git config:
      • your own credential helpers for https://github.com (keychain, gh auth git-credential) are reset;
      • a helper is added that answers with the bot's token;
      • git@github.com: and ssh://git@github.com/ remotes are rewritten to HTTPS, so pushes use the bot too.
    • GIT_AUTHOR_* / GIT_COMMITTER_* set to the bot.
  • No bot configured: nothing changes, and sessions act as the user.
  • loopway config / loopway login now keep the other keys in config.json when they rewrite it. Before, they would have dropped the github block.
  • README: a new "Acting as a GitHub bot" section under Threads.

Not in this PR, as discussed: skipping events the bot itself caused, and getting the token to the machine (it's copied by hand for now).

Tests

  • loadGithubBot: env over file, all-or-none, kept across loopway config.
  • botEnv against real git: author and committer identity, the user's helper replaced by the bot token for github.com, the SSH→HTTPS rewrite.
  • The dispatcher passes the bot env to runs only when a bot is configured.

Setup

No server changes, env vars or migrations. To use it:

  1. Create the bot account and add it to the repos.
  2. Make a token:
    • classic PAT with repo scope: needed for repos where the bot is only a collaborator;
    • fine-grained PAT (contents, issues and pull requests read/write): works on orgs that allow them.
  3. Add the github block to ~/.loopway/config.json. Use the bot's noreply email (<id>+<login>@users.noreply.github.com) so commits link to it.

Closes #31

🤖 Generated with Claude Code

With `github: { token, name, email }` in ~/.loopway/config.json (or
LOOPWAY_GITHUB_TOKEN/NAME/EMAIL), the dispatcher runs each session with
GH_TOKEN, a github.com credential helper that answers with the bot's
token (SSH remotes rewritten to HTTPS), and the bot as commit author and
committer. Without it, sessions keep acting as the user. `loopway config`
and `login` now keep other keys in config.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loopway Ready Ready Preview Oct 8, 2026 2:55pm UTC

Request Review

Comment thread packages/cli/src/threads/github.ts Resolved
Comment thread packages/cli/src/threads/github.ts Resolved
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcwhittemore

Copy link
Copy Markdown
Collaborator Author

tests are failing, figure out what is wrong and resolve them. Don't push till tests are passing and when you push, confirm they pass here.

mcwhittemore and others added 2 commits October 8, 2026 10:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcwhittemore

Copy link
Copy Markdown
Collaborator Author

The tests themselves were passing. CI failed at its last step, npm run format:check.

Cause: CI runs against this branch merged into the latest main. Since I branched, main gained Prettier and ESLint (#43), and two of my files (packages/cli/src/config.ts and packages/cli/test/cli.test.ts) weren't formatted the way Prettier wants.

Fix:

  • I merged origin/main into the branch with a merge commit, so nothing was force-pushed.
  • I ran Prettier on the changed files (30e2918).

Before pushing, I ran every CI step locally and all of them passed:

  • npm test: web 34, cli 31
  • npm run typecheck
  • npm run lint
  • npm run format:check

Confirmed here: the CI run on 30e2918 passed (run), and so did Vercel.

This branch was previously deployed

1 inactive deployment
Preview — 30e29186 Deployed Oct 8, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Loopway user for github?

1 participant