Actions runs/run/jobs/logs + fj agent skill #1

Open
multica-agent wants to merge 0 commits from donach-main into main
Collaborator

Upstream base 7f44ff1 plus: actions runs|run|jobs|logs (--attempt) against the Forgejo v16 API, human durations, v16-hint errors, en-US locale keys, skills/fj/SKILL.md for native agent use. Verified: cargo build/test, clippy, nix build, live runs/run against git.bitp.cz.

Upstream base 7f44ff1 plus: actions runs|run|jobs|logs (--attempt) against the Forgejo v16 API, human durations, v16-hint errors, en-US locale keys, skills/fj/SKILL.md for native agent use. Verified: cargo build/test, clippy, nix build, live runs/run against git.bitp.cz.
jobs/logs wrapped every error in "requires Forgejo v16 or newer", so a
mistyped job id on a v16 server read as a server problem. Ask the server
for its version on failure and add the hint only below v16; otherwise
surface the server's own message ("run job with id N: resource does not
exist").

Version marker 0.6.0-donach.2.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The bundled skill carried another project's rules (donach-bot repo,
proof-gate ntfy handoff, "agents never close issues") and command
shapes that don't match this build (a review flow fj can't submit,
--repo placement). Nothing about SSH either, so agents kept cloning via
port 22 and the scp-style form, which cannot carry a port.

Now: instance facts (bare https://git.bitp.cz, SSH on :2300 as forgejo),
the three ways fj resolves host+repo, every command shape run against
the live server, the run-ID vs run-number trap, and a CI triage recipe
that keeps multi-thousand-line logs out of the agent's context.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
fj issue|pr comment --attach FILE (repeatable) uploads each file to the new
comment and appends a Markdown link per file to its body; images embed
inline. fj issue attach N FILE... and fj pr attach [-p N] FILE... upload to
the issue or PR itself and print the links. Files are read before anything
is posted. Skill documents the commands. Version 0.6.0-donach.3.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Grok added 11 commits 2026-10-02 21:08:11 +02:00
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`fj actions cancel <run-id>`, `fj actions artifacts [--run ID]` (paged
until a short page, since the endpoint has no total-count header), and
`fj actions artifact download|delete <id>`. Download writes `<name>.zip`
by default. `runs`, `run` and `jobs` print the raw API objects under
`--json`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`list <ref>` shows the combined state of a commit, branch or tag and one
line per context; `set <sha> --state ... --context ...` creates a status.
Both honour `--json`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
repo: branch (list/create/delete, protection rules) and file
Some checks are pending
fj-test fj status set test
fj-test-2
9764427d0c
`fj repo branch list|create|delete` and `fj repo branch protection
list|view|create|delete`, with the common protection flags on create.
`fj repo file <path> [--ref REF] [-o FILE]` prints a file's raw bytes,
resolving LFS pointers. All accept `-r owner/repo` / `-R remote` and the
list/view commands honour `--json`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The combined-status endpoint returns `"state": ""` and `"sha": ""` for a
ref with no statuses, which the typed enum rejects. Blank the state to
null and parse again, and fall back to the given ref for the header.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- pr review approve|request-changes|comment (with --inline PATH:LINE:TEXT),
  request|unrequest reviewers, dismiss.
- pr ready / pr draft toggle the WIP title prefix; pr reopen, issue reopen.
- pr update rebases (or --merge) the branch onto its base.
- pr land: approval gate, server-side rebase when behind (approval carries
  over to the head fj rebased), CI wait, fast-forward merge pinned to the
  checked head, then verifies the base branch moved.
- pr merge --require-approval and --auto (merge when checks succeed); merges
  are pinned to the head that was fetched.
- issue/pr create --label --assignee, pr create --reviewer; unknown labels
  fail before anything is created.
- --json on pr view/search/status/review list/create and issue
  view/search/comments/create.
- FJ_TOKEN overrides the stored login, for approving as another account.
- Fix: pr status crashed on commits with no statuses (combined status sends
  an empty state) and on merged PRs (message used $created_at).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	localization/en-US/messages.ftl
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- issue list: metadata listing (state default open, labels, milestone,
  assignee/creator/mentions with @me, since/before, kind issues|prs|all,
  sort, limit with auto-paging past the 50/page cap). One line per item with
  labels, assignees, milestone and age; total to stderr.
- issue summary: open/closed counts per label, milestone and assignee.
- issue board (alias kanban): columns from prefixed labels (default
  state:), or exactly --columns with bare labels.
- issue view N --comments: body and all comments in one call.
- issue set N...: bulk labels add/remove, milestone, assignees, state,
  comment. Names resolved first; per-item results; fails at the end if any did.
- issue close N... -w MSG: bulk close, message asked once.
- --json on all of the above. Version 0.6.0-donach.5.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Forgejo only creates access tokens via BASIC auth (login + password), never
with an existing token. Add 'fj user token' so an unprivileged bot account can
mint its own CI token into a 0600 file without it ever hitting stdout/stderr
(401/403/422 server messages are surfaced without echoing secrets).

- create: validates scopes up front (read:/write: + activitypub|admin|issue|
  misc|notification|organization|package|repository|user, or all), refuses a
  group-/world-readable password file, writes the sha1 value to --out (0600,
  refuses to overwrite without --force, '-' not allowed).
- list: prints id/name/scopes only (never the value or Forgejo's last-8).
- delete: takes a token id (from list) or a token name.
- --user defaults to the logged-in login (what 'fj whoami' shows).
- bump 0.6.0-donach.5 -> 0.6.0-donach.6; document in SKILL.md
Fix the REQUEST_CHANGES findings from the agy and grok reviews of
feat/user-token-create:

- Reserve --out BEFORE minting: create_new with mode 0600 at open time;
  refuse symlinks, /dev/* and '-'. With --force, write a fresh 0600 temp
  file in the same directory and rename atomically over the target, never
  writing into the existing inode. On a failed mint the empty file is
  removed; if the local write fails after minting, the just-minted token
  is deleted server-side and the failure says so.
- Scopes now match Forgejo: bare 'all' and 'public-only', plus
  read:/write: + the nine categories. read:all/write:all are rejected
  locally, before any request.
- The password file is the whole content minus exactly one trailing \n or
  \r\n: no trimming (spaces survive), multi-line files are refused with a
  clear error, and only 0600 files are accepted.
- Token commands no longer require an existing fj login: the basic-auth
  client is built without keys.get_api(); --user defaults to the username
  stored in keys.json (read locally, no API call), filled in at login
  time; without any stored login, --user is required and the error says
  so.
- list/delete page through ALL tokens via .all(); delete takes --id N or
  --name NAME (no more guessing from a positional), and a name matching
  several tokens is refused with their ids listed.
- LOW: cleartext http:// hosts are refused for these commands unless
  --insecure-http; no error path can print a response body containing the
  token (errors carry status + server message); the user input echoed by
  the old 'no token named ...' is gone; password and freshly-minted token
  values live in zeroize::Zeroizing buffers.
- Tests now match their names: unique temp dirs cleaned up on drop,
  symlink refusal, 0600 at creation, rename-on-force on a pre-existing
  0644 file (new inode), multi-line password refusal, inner-space
  passwords, scope acceptance/rejection incl. read:all and public-only,
  and failed-mint cleanup.
- reserve_out_file: open parent dir once (O_NOFOLLOW, owned-by-us check),
  create file with O_NOFOLLOW|O_CREAT|O_EXCL 0600 via openat, verify the
  held fd with fstat (regular file, ours, st_nlink==1); keep the fd OPEN
- write_token_file: write through the reserved handle (no path reopen),
  fchmod 0600 + sync_all before commit
- force temp names: unpredictable CSPRNG suffix (pid alone was guessable)
- existing directory at --out refused up front (no more stranded minted
  token + plaintext temp on EISDIR)
- commit failure after mint: delete the minted token server-side and
  remove the plaintext temp file
- --out with no directory part: empty parent treated as "."
- --user default: pure local lookup; no get_api()/FJ_TOKEN; require
  --user when stored login has no username
- token delete --name: exact match, no trimming, whitespace-only refused
- id/name presence validated before reading the password file
- read_password_file: intermediate content buffer is Zeroizing
- token_delete: bind the success message variable as 'id' to match the
  .ftl pattern 'deleted token {$id}' (was positionally bound as
  'target', panicking with 'Unknown variable: $id' on every
  successful delete, exit 101).
- token delete: reject --id AND --name together in step 1b (XOR)
  BEFORE the password file is read or any client is built.
- reserve_out_file parent check: accept parents owned by us OR sticky
  (e.g. root-owned 1777 /tmp) OR not group-/world-writable; still
  refuse a group-/world-writable non-sticky dir owned by others.
  The old blanket st_uid == geteuid() check blocked /tmp, /var/tmp,
  shared CI trees and container mounts with a misleading
  'does not exist' error.
- FD hygiene: parent dir fd is an OwnedFd (closed on every error and
  success path, no more close() on selected paths only); O_CLOEXEC on
  the parent open and the openat of the reserved file.
- commit_out_file: fsync the parent directory after the rename so the
  commit survives a power loss.
- New tests: every msg-user-token-* message formats without panicking
  using the same arguments the command code passes (would have caught
  the delete-success variable mismatch); parent-rule decision table
  and end-to-end reserve in sticky/world-writable/own/read-only
  parents.

cargo test: 46 passed, 0 failed.
Hold the parent directory fd (OwnedFd) in ReservedOut from reserve through
commit instead of dropping it. commit_out_file now performs the --force
rename via renameat(2) relative to that same dirfd (both operands inside the
one verified directory, so no swapped/parent-follow), fsyncs through the
same handle, and then re-checks with fstatat(AT_SYMLINK_NOFOLLOW) that the
final name still names the very inode the token was written through
(st_dev/st_ino match, regular file, nlink==1). On mismatch (name swapped for
a symlink / unlinked / replaced) the commit fails, so token_create deletes the
just-minted token server-side, removes the local file, and never reports
success. Same verification runs on the non-force path (the reserved file
itself).

Adds a test hook (PRE_COMMIT_HOOK) run in the write->commit window and a test
that swaps the final name for a symlink between reserve and commit, asserting
failure + local cleanup + that the server DELETE was issued (mock server).
47 passed, 0 failed.
- reserve_out_file: use raw OsStr bytes (not to_string_lossy) for the
  output name so non-UTF-8 --out names are created/verified verbatim
- parent rule: extract into parent_dir_decision (single source of truth);
  refuse a foreign group-/world-writable non-sticky parent with a specific
  out_parent_untrusted message instead of the misleading missing message
- token_create: when the server-side delete of the minted token fails, say
  the token MAY be ORPHANED (with its id), not that it 'was deleted'
- commit_out_file: fsync the directory on BOTH the force and non-force
  paths and check the result
- thread-local PRE_COMMIT_HOOK so one test's commit can't fire another's
- refuse a blank/whitespace --name before the password file is read
  (create and delete), via the shared token_name_is_blank predicate
- new tests: non-UTF-8 name, replaced-regular-file (locks st_ino/nlink/
  dev conjuncts), foreign-0777-parent, blank-name, and arg-name pairing
  (all fail on revert); existing parent-rule tests now drive the real
  predicate. (PR #12 r6)
- MEDIUM: on token_create failure, fstat the still-open fd and unlinkat only
  a directory entry in the open parent whose st_dev/st_ino match that inode
  (final name -> reserved name -> parent-dir scan); never unlink a name that
  fails the check. Error messages now say honestly whether the plaintext
  file was removed.
- cfg(test) fault-injection hook FAIL_DIR_FSCI... (FAIL_DIR_FSYNC) drives the
  post-renameat dir-fsync failure path; two new tests lock it down.
- Nits: single TOKEN_MESSAGES const table shared by call sites and the
  arg-name/format tests; blank-name order locked via a nonexistent password
  file; exact 'was deleted'/'could NOT be deleted' asserts; --force temp name
  from raw bytes (OsStrExt); fixed stale assert text; foreign 0777 parent
  message asserted (drives reserve_out_file when root); run_pre_commit_hook
  takes the hook out of the mutex before calling it.
Round 8 (PR #12):
1. remove_out_file now WIPEs the still-open handle first (ftruncate+fsync),
   then unlinks EVERY directory entry naming the inode (not just the target
   name), and re-checks via fstat: a surviving link is reported as WipedLinkRemains
   rather than silently claiming the secret is gone. New tests drive a
   same-dir hard link and a renamed-away file with a planted symlink.
2. Call sites build FluentArgs from the shared TOKEN_ARG table via tftl_args!
   (no longer bare idents that the shared ftl_*! macros stringify into the arg
   name), so renaming a call-site/message argument to a name the .ftl does not
   reference is caught by the every_token_message_arg_names_match test.
3. The two failed_mint_* tests now drive the real token_create mint-failure
   arm through the shared in-test HTTP server (400 on mint) instead of a
   test-only abort helper, so they exercise the production error path.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin donach-main:donach-main
git switch donach-main

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff donach-main
git switch donach-main
git rebase main
git switch main
git merge --ff-only donach-main
git switch donach-main
git rebase main
git switch main
git merge --no-ff donach-main
git switch main
git merge --squash donach-main
git switch main
git merge --ff-only donach-main
git switch main
git merge donach-main
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
donach/fj!1
No description provided.