Skip to content

feat(miner): add gittensory-miner init --interactive onboarding wizard - #5624

Closed
JSONbored wants to merge 1 commit into
mainfrom
init-interactive-wizard
Closed

feat(miner): add gittensory-miner init --interactive onboarding wizard#5624
JSONbored wants to merge 1 commit into
mainfrom
init-interactive-wizard

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Adds an opt-in --interactive flag to gittensory-miner init: prompts for a masked GITHUB_TOKEN and a coding-agent provider (claude-cli/codex-cli/agent-sdk/noop) from an explicit menu, with provider-specific model/timeout follow-ups (skippable via a blank line).
  • Writes the collected values to a starter .env in the state dir (mode 0600), not auto-loaded by the CLI itself — mirrors the existing systemd EnvironmentFile=/.gittensory-miner.env.example convention already documented for fleet mode.
  • Automatically reruns doctor after a successful interactive init so the operator immediately sees whether the new config passes, reusing doctor's existing check list/output formatting rather than duplicating it.
  • Plain init (no flag) is untouched — verified via a dedicated regression test asserting identical output and zero interaction with the injected input/output streams.
  • The token is never printed back anywhere, including the summary screen — verified via an invariant test scanning every output write for the raw secret.

Along the way

Manually running the real CLI end-to-end with piped stdin (printf 'token\n1\n...' | gittensory-miner init --interactive) surfaced a real bug the mocked unit tests hadn't caught: a piped/non-TTY stdin can deliver several answers in a single data chunk (no "one keystroke per event" guarantee the way a raw-mode TTY has), and the first version of the prompt reader discarded everything after the first prompt's newline, silently dropping the next prompt's answer and hanging forever. Fixed by threading a small per-wizard-run leftover buffer through the prompt reader, with new regression tests covering both the single-chunk and keystroke-by-keystroke delivery shapes.

Test plan

  • npm run typecheck
  • npm run build:miner / npm run test:miner-pack
  • New test/unit/miner-init-interactive.test.ts (26 cases): happy path, re-prompt-on-invalid-input for both the token and provider menu, provider-specific companion prompts (present/skippable), masking/backspace/raw-mode-toggle behavior, Ctrl+C abort, the piped-chunk and partial-leftover regressions, the never-echoed-token invariant, and the non-interactive byte-for-byte regression
  • Full miner suite (148 files / 1773 tests) green
  • Branch coverage: 100% of every new line/branch in this diff (verified via lcov branch-map inspection; pre-existing gaps elsewhere in the file are untouched by this PR)
  • Live end-to-end verification via the real bin/gittensory-miner.js with piped stdin, confirming the fix, the .env file contents/perms, and the automatic doctor rerun (including a real FAIL surfacing correctly with exit code 1)

Closes #5176

Adds an opt-in --interactive flag to `init` that prompts for a masked
GITHUB_TOKEN and a coding-agent provider (with provider-specific
model/timeout follow-ups), writes a starter .env to the state dir, and
reruns doctor so the operator immediately sees whether the config
passes. Plain `init` is untouched. Also fixes a real bug caught while
manually verifying the CLI end-to-end: piped/non-TTY stdin can deliver
multiple answers in a single data chunk, which an earlier version of
the prompt reader silently dropped past the first newline.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 84f669e Commit Preview URL

Branch Preview URL
Jul 13 2026, 12:44 PM

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.02%. Comparing base (b189eaf) to head (84f669e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5624      +/-   ##
==========================================
+ Coverage   95.01%   95.02%   +0.01%     
==========================================
  Files         575      575              
  Lines       45738    45837      +99     
  Branches    14661    14661              
==========================================
+ Hits        43459    43558      +99     
  Misses       1528     1528              
  Partials      751      751              
Flag Coverage Δ
shard-1 43.79% <1.01%> (-0.11%) ⬇️
shard-2 35.68% <6.06%> (-0.06%) ⬇️
shard-3 32.16% <6.06%> (-0.19%) ⬇️
shard-4 30.81% <1.01%> (-1.77%) ⬇️
shard-5 32.51% <1.01%> (+0.72%) ⬆️
shard-6 44.59% <100.00%> (+0.52%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/cli.js 100.00% <ø> (ø)
packages/gittensory-miner/lib/laptop-init.js 99.06% <100.00%> (+0.80%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-13 17:22:27 UTC

6 files · 1 AI reviewer · 1 blocker · readiness 100/100 · CI green · dirty

⏸️ Suggested Action - Manual Review

Review summary
This adds an interactive setup wizard to `gittensory-miner init` with a custom raw byte-level line reader that handles masked token input, provider menu selection, and companion prompts, then writes a starter .env (mode 0600) and reruns doctor. The described 'discarded leftover after first newline' bug and its fix (threading `reader.leftover` through `promptRaw`) is well-reasoned and directly tested with both single-chunk and keystroke-by-keystroke regression tests. Plain `init` (no flag) is verified untouched via a dedicated test that throws if the injected input stream is read at all, and the token-leak invariant test scanning every output write is a solid safety net.

Nits — 6 non-blocking
  • packages/gittensory-miner/lib/laptop-init.js:332-390 promptRaw is a 61-line function with cyclomatic complexity ~15 and nesting depth 5 (per the external brief); consider extracting the leftover-consume logic or the finish/consume closures into named helpers for readability, though it's well-commented.
  • packages/gittensory-miner/README.md line addition claims interactive init 'makes no network calls beyond what doctor already makes (none)' — worth double-checking `--verify-token` isn't combinable with `--interactive` in a way that contradicts this, since runInit still supports both flags together via args.includes.
  • laptop-init.js: CODING_AGENT_PROVIDERS is duplicated as a local literal mirroring CODING_AGENT_DRIVER_NAMES in driver-factory.ts (justified by the no-runtime-dependency comment), but nothing guards these two lists from drifting apart — consider a shared test or comment cross-reference in driver-factory.ts pointing back here.
  • bin/gittensory-miner.js:64-69 the doctor rerun after interactive init calls `runDoctor` synchronously without awaiting anything async inside it, worth a quick sanity check that runDoctor's signature is fully synchronous (it's imported and called without `await` elsewhere too, so this appears consistent).
  • Consider extracting the per-character consume loop in promptRaw (laptop-init.js:355-378) into a small dispatch table or separate function per control character to reduce the reported complexity/nesting.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
Signal Result Evidence
Code review ❌ 1 blocker 1 reviewer
Linked issue ✅ Linked #5176
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 36 merged, 326 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 326 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 44 PR(s), 326 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 13, 2026
@JSONbored

Copy link
Copy Markdown
Owner Author

Superseded: #5176 was independently implemented and merged via #5621 while this PR was open. Closing as duplicate — no action needed on this branch.

@JSONbored JSONbored closed this Jul 13, 2026
@JSONbored
JSONbored deleted the init-interactive-wizard branch July 13, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add gittensory-miner init --interactive first-run onboarding wizard

1 participant