Commit graph

19 commits

Author SHA1 Message Date
87b3cf98d9 Merge pull request 'auth login: default to least-privilege token scopes' (#19) from fix/auth-login-scopes into main 2026-07-26 22:00:12 +00:00
907917a870 Merge pull request 'install-apt: fail fast when the registry has no Release file' (#18) from fix/install-apt-fail-fast into main 2026-07-26 22:00:09 +00:00
kimi-reviewer-andresmgsl
955ce393fc auth login: default to least-privilege token scopes (#9)
Tokens minted by stoke auth login previously got read/write on every
non-admin scope. Default to the reduced set the common issue/PR/repo
commands need (read/write issue + repository, read user + organization),
add --full-scopes to restore the old behavior and --scopes <csv> for a
custom list, and print the granted scopes after login.
2026-07-26 21:43:06 +00:00
kimi-reviewer-andresmgsl
8255c568b1 install-apt: fail fast with a clear message when the registry has no Release file 2026-07-26 21:41:16 +00:00
3e93b20ae6 Add stoke repo clone with ephemeral token handling (#14)
Closes #13.

Independently verified end-to-end: token absent from .git, clean remote URL,
no extraHeader persisted. 53/53 tests pass.
2026-07-26 21:24:42 +00:00
036364f844 Address review: pager owns limit/page, reject GET+input, label delete exclusivity 2026-07-26 20:52:29 +00:00
355fcc1f67 Add release, label, and api commands (v1.3.0) 2026-07-26 20:31:07 +00:00
1b990d523a Add stoke repo clone with ephemeral token handling (#13)
Clone repositories from the configured Forgejo instance using the stored
session. The token is passed to git through GIT_CONFIG_* environment-based
config (http.<url>.extraHeader) with GIT_TERMINAL_PROMPT=0, so it never
appears in the remote URL, on the command line, in logs, or in the cloned
repository's .git/config. Git streams its own output and its exit status is
forwarded to the caller.

Supports an optional destination directory plus --branch, --depth and
--origin. Adds tests covering destination handling, exit-status
propagation, remote naming, depth validation and credential redaction.
2026-07-23 22:44:21 +00:00
kimi-reviewer-andresmgsl
7deab688a2 Fix install-apt test return after rebase 2026-07-23 00:08:06 +00:00
d959d2a6f4 Polish PR review CLI and harden install-apt (v1.2.1)
- Accept approve/approved review event aliases; print review html_url
- Harden pr show against missing user/head/base; clarify body-file wins
- Add tests for whitespace-only comments, approved alias, review URL
- Timeout the CLI-boundary HTTP fixture; clean up install-apt test trees
- Clearer refuse-to-overwrite message when nodesource.list already exists
- Merge Node 22 NodeSource bootstrap (from fix/apt-nodejs-bootstrap)
2026-07-23 00:06:15 +00:00
41b65a2bbd Merge pull request 'install-apt: bootstrap Node 22 when distro nodejs cannot satisfy the dependency' (#5) from fix/apt-nodejs-bootstrap into main 2026-07-22 23:19:04 +00:00
0ecd935528 install-apt: address review nits — apt-readable file modes, test cleanup, clearer refusal error
- chmod 0644 every keyring and sources.list entry after writing: tee
  inherits the caller's umask, and under e.g. umask 077 apt's
  unprivileged _apt user could not read the keyring
- Tests now run the script under umask 077 and assert the 0644 modes
  (mutation-checked: dropping the chmod fails a test), and remove their
  temp directories on exit
- Refusal error now states that metadata was already refreshed before
  concluding the existing nodesource.list is unsuitable

Verified on fresh debian:13 under umask 077: all four files 0644,
install succeeds. npm test 32/32.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 23:17:20 +00:00
444470301c test: stubbed shell tests for the NodeSource bootstrap logic
Covers the scenarios codex-reviewer recommended: suitable candidate
already present (incl. epoch stripping), missing metadata healed by a
refresh, bootstrap on too-old distro nodejs, bootstrap failure, and the
refuse-to-overwrite branch for a user-managed nodesource.list. Every
scenario runs under a localized LC_ALL with an apt-cache stub that only
emits the English Candidate: label under LC_ALL=C, so locale-safe
parsing is regression-tested (mutation-checked: dropping LC_ALL=C fails
3 tests).

install-apt.sh gains STOKE_APT_ETC to redirect /etc/apt to a throwaway
directory under test, following the script's existing env-override
pattern. Real-container flow re-verified on debian:13.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 22:01:51 +00:00
kimi-reviewer-andresmgsl
d88cb484d3 Address PR #4 review feedback
- pr comment now rejects whitespace-only bodies and preserves raw body.
- pr review accepts request_changes alias in addition to request-changes.
- Add CLI-boundary regression test proving review body-file whitespace is
  preserved through the CLI and sent byte-for-byte to the API.
- Update README option help text for the new alias.
2026-07-22 21:57:30 +00:00
kimi-reviewer-andresmgsl
d56e509649 Preserve raw review body while validating emptiness
Validate non-APPROVED reviews using trim().length, but send the original
unmodified body to the API so Markdown whitespace is preserved.
2026-07-22 21:37:56 +00:00
kimi-reviewer-andresmgsl
6b0b3729f3 Fix review event mapping and body validation
- Map CLI 'approve' to Forgejo's expected 'APPROVED' event.
- Require a non-empty body for request-changes and comment events.
- Update API test expectation and add CLI tests for body validation.
2026-07-22 21:32:06 +00:00
kimi-reviewer-andresmgsl
8e6907a11e Add pr show, comment and review commands
Adds CLI commands for inspecting a pull request, posting a comment, and
submitting an APPROVE/REQUEST_CHANGES/COMMENT review. Includes API client
methods, CLI wiring, and tests.
2026-07-22 21:20:46 +00:00
Claude
f5615455bf Add apt distribution: deb packaging, registry publish, docs (#1)
Implements #1 — stoke installable with apt-get install stoke.

Packaging:
- scripts/build-deb.sh: builds dist/stoke_<version>_all.deb from a clean
  staging copy (src + fresh npm ci --omit=dev), pure-JS Architecture: all,
  Depends: nodejs (>= 22.12), /usr/lib/stoke payload with /usr/bin/stoke
  symlink, copyright + changelog, normalized permissions. Lintian-clean.
- scripts/publish-deb.sh: uploads a .deb to the Forgejo Debian registry
  (owner/distribution/component parameterized, defaults heavy-duty/
  stable/main), authenticating with STOKE_TOKEN or the stoke login token.
- scripts/install-apt.sh: consumer-side one-time setup — adds the
  registry key and apt source, then apt-get install stoke. Falls back to
  a [trusted=yes] source when apt's sqv verifier rejects the forge's
  registry signature (known upstream Forgejo signing bug; the script
  prefers the signed source so setups heal once the forge is fixed).
- .forgejo/workflows/release.yml: on v* tags — test, build, publish to
  the heavy-duty registry, attach the .deb to the release page. Needs a
  runner and a RELEASE_TOKEN secret with org package write.

New command:
- stoke pr merge (-n, --method merge|rebase|rebase-merge|squash,
  --title, --message, --delete-branch) — gap found while merging !2.

Docs and housekeeping:
- README: 'Install with apt' as the primary installation method with
  manual setup and dpkg fallback, signature caveat, pr merge reference,
  Packaging and releasing section with a release checklist.
- dist/ gitignored; version bumped to 1.2.0.

Verified end-to-end on this machine: built the deb (lintian-clean),
published it to the Forgejo Debian registry, installed it with
apt-get install stoke via install-apt.sh, and confirmed the installed
CLI works against the live forge. The test upload was removed from the
personal namespace afterwards; publishing under heavy-duty needs an
org-member token (401 reqPackageAccess with this restricted account).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:41:02 +00:00
Claude
69704cdf9b Audit: fix auth/config bugs, add issue/pr create, tests and docs
Fixes found during a full audit of the CLI:

- auth logout: remote token revocation always failed with 401 because
  Forgejo only accepts Basic auth on the token endpoints. Logout now
  asks for (or accepts) the account password, supports --password,
  --password-file and --local-only, and clearly reports when the token
  is left active.
- Silent password prompt actually echoed the password on a TTY:
  overriding rl.write does not suppress readline echo. Switched to the
  callback readline module and mute _writeToOutput instead (the
  readline/promises interface does not honor that hook).
- Global --config flag was silently ignored: config paths were resolved
  at require time, before the preAction hook set STOKE_CONFIG_FILE.
  Paths are now resolved lazily on every access.
- XDG_CONFIG_HOME handling put the config in $XDG_CONFIG_HOME/.config/stoke;
  per the XDG spec it now resolves to $XDG_CONFIG_HOME/stoke.
- repo create: --auto-init defaulted to true with no way to disable it;
  added --no-auto-init.
- repo import/import-batch: a GitHub token was required even for
  non-GitHub services (e.g. --service git), making those imports fail
  without gh/GITHUB_TOKEN. Tokens are now only auto-resolved for the
  github service; batch imports resolve per entry and memoize.
- Branding leftovers: 'Run: forgejo auth login' hint and
  forgejo-cli/1.0.0 User-Agent now say stoke (UA tracks pkg.version).
- Added request timeouts (30s default, 10m for migrations).
- --limit and --team-id are validated as integers instead of silently
  misbehaving on garbage (NaN made -l show all results).

New commands (per the repo's every-operation-becomes-a-command design):

- stoke issue create (title/body/body-file/assignees)
- stoke pr create (head/base/title/body/body-file)

Tests and metadata:

- New test suite on the built-in node:test runner (25 tests) covering
  config resolution/persistence, the API client with a mocked fetch,
  and end-to-end CLI behavior. npm test previously matched no files.
- package.json: engines >=22.12.0 (required by commander@15 — the
  README claimed Node 18), repository, keywords, author; version 1.1.0.
- README: corrected Node requirement, documented repo rename (was
  missing), issue create, pr create, logout options and revocation
  caveat, --no-auto-init, XDG behavior, import token rules, testing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:28:23 +00:00