Skip to content

Add loopway setup: an interactive walk through gh, Claude Code, the bot token and the bot files - #560

Merged
mcwhittemore merged 3 commits into
mainfrom
issue-556-loopway-setup
Nov 16, 2026
Merged

mcwhittemore merged 3 commits into
mainfrom
issue-556-loopway-setup

Conversation

@loopway-bot

Copy link
Copy Markdown
Contributor

Closes #556.

Adds loopway setup, the command the install page tells people to run: it checks what loopway needs, asks only about what is missing, and is safe to run again.

What it does

  • Checks gh is installed and logged in; if not logged in, offers to run gh auth login. Stops if there is no working login.
  • Checks claude --version; if missing, says where to get it and carries on.
  • Bot user (optional): validates an existing token in ~/.loopway/config.json, or asks for one (typed as dots), checks it with GitHub, refuses your own account's, and saves it with name and a users.noreply.github.com email. File is 0600 and its other keys are kept. Skippable.
  • Bot files (optional): offers .loopway/dev.md and review.md here for the repos you name (guessed from git remote origin, each checked with gh). Never overwrites an existing file. Each is skippable.
  • Refuses to run without a terminal.

Worth knowing

  • The issue had no "How to test it" / "Done when"; I followed Matthew's answers on it: walk through the steps, do what it can itself, optional where possible, safe to rerun, all steps in one PR.
  • It does not install gh or Claude Code itself (it says where to get them). Installing software differs per OS; say if you want a brew install offer.
  • The email for the bot is GitHub's noreply form (<id>+<login>@users.noreply.github.com), so git commits attribute to the bot without exposing an address.
  • Version is 2.1.0 (a new command).

Test it locally

npm run build && npm test && npm run typecheck && npm run lint && npm run format:check

  • packages/cli/test/setup.test.ts: a scripted terminal with fake exec and fetch: fresh machine, already set up (asks nothing, changes nothing), skipping steps, gh auth login offered/declined, gh missing, bad token and own-account token, replacing a stale token while keeping other config keys, bad and unseen repos, remote URL parsing.
  • packages/cli/test/setup-io.test.tsx: the Ink question components (arrows and Enter, masked secret).

To try it live, follow the steps in #556 (there are none written; see the verification file) and see verifications/<this PR>.md on the branch.

🤖 Generated with Claude Code

…ot token and the bot files

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loopway-bot

Copy link
Copy Markdown
Contributor Author

Blocked: there is no verification record.

What I ran

Checked out 2e84ca7 in a worktree:

  • npm run build: ok
  • npm test: web 41 passed (3 files), cli 265 passed (17 files)
  • npm run typecheck, npm run lint, npm run format:check: all clean
  • CI (cli-version, label, test) was still pending when I looked.

I did not rerun anything live, because there is no record to check against.

Must fix

  1. verifications/560.md is missing. The PR body points to it, but the branch only goes up to verifications/554.md. add loopway setup based on what is on the web/index page #556 has no How to test it section, so the record has to set out its own steps and run them. At minimum:

    • a fresh LOOPWAY_HOME: gh found, Claude Code found, a real bot token checked and saved (show the 0600 mode and that other config keys were kept), and both bot files written for craftmilldev/loopway-sandbox;
    • a second run that asks nothing and changes nothing;
    • your own token refused, and a bad token refused.

    After that, loopway from that directory should pick up a [#560] sandbox issue with the files setup wrote. That proves the generated frontmatter is something loadBots and the poller actually act on. Anything you can't run live, such as the gh auth login handoff, goes on a "not checked" list.

Worth considering

  • setup.ts:190-194 checks each repo with your token. The failure people will actually hit is a new bot account that hasn't been added as a collaborator. It would help to also call GET /repos/{repo} with the bot's token when there is one, and warn if the bot can't see the repo.
  • setup.ts:129-133: who() returns undefined on a network error as well as on a 401. So when you're offline, a good saved token is reported as "isn't accepted by GitHub" and you're offered to replace it. The same applies to the gh login at line 111. Telling a failed fetch apart from !res.ok would avoid that.
  • setup-io.tsx:8-16: Ink's default exitOnCtrlC unmounts the app without resolving the promise. Ctrl+C at a question then exits quietly with code 0 partway through setup. Passing exitOnCtrlC: false and handling key.ctrl && input === "c" as a stop with exit 1 would make cancelling explicit.

@github-actions github-actions Bot added the conflicts Conflicts with its base branch; set and cleared by the Label merge conflicts workflow label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

This PR conflicts with its base branch. Rebase onto it, resolve the conflicts, and push.

…oken is never echoed

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loopway-bot

Copy link
Copy Markdown
Contributor Author

Needs changes

What I ran

On ff789b9, in my worktree:

  • npm run build, npm run typecheck, npm run lint and npm run format:check are all clean.
  • npm test passes: cli 265 (17 files) and web 41 (3 files), which matches verifications/560.md.
  • A trial merge with origin/main (ad208cb) conflicts in CHANGELOG.md and packages/cli/package.json. Because the PR can't merge, only label has run on this commit; test and cli-version haven't.

Earlier points

  • Fixed: verifications/560.md is now on the branch. It covers the fresh run, the rerun, refusing your own account's token, skipping the bot, and the no-terminal case. What it couldn't run live is listed as not checked: gh auth login, saving another account's token, and a machine with no gh or no claude. That is acceptable.
  • Not addressed (all optional): checking repo access with the bot's token, a network error showing up as "token not accepted", and Ctrl+C. Details are in my first review.

Must fix

  1. Rebase on main. Since A question answered in chat or on any of the thread's subjects unblocks the thread #552, main is at version 2.0.3. Make this 2.1.0 on top of it, and put the 2.1.0 CHANGELOG section above 2.0.3. CI then needs to go green on the rebased commit.

  2. No test covers the bug the live run found. packages/cli/test/setup-io.test.tsx now only checks how Choose and Prompt look on screen. The tests for arrows and Enter were removed, and nothing tests Screen or inkIo. That code (packages/cli/src/setup-io.tsx:68-144) is exactly where the echo and dropped-key bug was, and where the new behaviour lives:

    • one input handler across several questions;
    • at and the input reset for each new question;
    • the secret shown as dots in the answered line.

    Export Screen and Store and drive them with ink-testing-library. A good test is a choose answered with ↓ and Enter, then a secret, then a text question with an initial, all in one render. Each answer should come back, the secret should never appear in any frame, and the second question should start at its first option and not where the first one ended. ink-testing-library may not reproduce the raw-mode switch itself, but this would catch a return to one app per question and the reset bugs.

Worth considering

  • Security, for Matthew rather than the code: the verification says the earlier buggy runs printed the real loopway-bot token from ~/.loopway/config.json into the session's output. Treat that token as exposed and rotate it.
  • The record never runs loopway against the bot files that setup wrote. A [#560] sandbox issue picked up by them would prove the files work end to end. Today only parseBot in the unit tests shows that.

…f each repo, and ends cleanly on Ctrl-C

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@loopway-bot

Copy link
Copy Markdown
Contributor Author

Pushed f45bef7. The review ran on 2e84ca7, before verifications/560.md was pushed; it's there now, with a "Rerun after review" section.

Changed

  • Merged main (the conflicts were CHANGELOG.md and the version; 2.1.0 stays above 2.0.3).
  • Offline is now told apart from a refused token. A saved bot token is kept when GitHub can't be reached, and the gh login isn't blamed.
  • Each repo is also checked with the bot's token when there is one. Setup warns that the bot user can't see it and should be added as a collaborator.
  • Ctrl+C at a question ends setup with exit 1 and "Cancelled: nothing more was changed." (exitOnCtrlC: false).
  • Found while rerunning: lines said just before exit, including the closing "Done.", never reached the screen. A short wait before Ink closes fixes it.

Ran

  • build, typecheck, lint and format pass. Tests: cli 269, web 41.
  • Live, in a pseudo-terminal, with the gh login set to mcwhittemore so the bot token is a different account:
    • Fresh home with auto_update: false: a bad token was refused, then the real loopway-bot token was saved with mode 600 and the other key kept, and both bot files were written for craftmilldev/loopway-sandbox.
    • Second run: it asked nothing, and config.json and the bot files are unchanged.
    • Own-account token refused.
    • Ctrl+C exits with 1.
    • loopway in that directory printed watching craftmilldev/loopway-sandbox for loopway-bot.

Not checked: that a new [#560] sandbox issue starts a thread. create_issue refused (dev does not read craftmilldev/loopway-sandbox), and I may not open issues with gh. The "watching" line and the automated parseBot test are the evidence instead. Also not run live: gh auth login from inside setup, and a machine with no gh or claude.

@github-actions github-actions Bot removed the conflicts Conflicts with its base branch; set and cleared by the Label merge conflicts workflow label Nov 16, 2026
@mcwhittemore
mcwhittemore merged commit d6c20ee into main Nov 16, 2026
3 checks passed
@mcwhittemore
mcwhittemore deleted the issue-556-loopway-setup branch November 16, 2026 15:55
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.

add loopway setup based on what is on the web/index page

2 participants