Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
name: release draft
name: release

# Every push to main is checked; only a commit whose VERSION has no tag yet
# builds, tags, and publishes. Manual runs retry the same decision on main.
on:
push:
tags: ['v*']
branches: [main]
workflow_dispatch:
inputs:
tag:
description: Existing tag matching VERSION on main (never creates a tag)
type: string
required: true

permissions:
contents: read

concurrency:
group: release-${{ inputs.tag || github.ref_name }}
group: release
cancel-in-progress: false

jobs:
prepare:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
commit: ${{ steps.tag.outputs.commit }}
version: ${{ steps.tag.outputs.version }}
release: ${{ steps.plan.outputs.release }}
commit: ${{ steps.plan.outputs.commit }}
version: ${{ steps.plan.outputs.version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.sha }}
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.12'
- name: Verify existing main-line tag and VERSION
id: tag
env:
PT_TAG: ${{ inputs.tag || github.ref_name }}
run: python scripts/release.py check-tag --tag "$PT_TAG"
- name: Decide whether VERSION is new
id: plan
run: python scripts/release.py plan --commit "$GITHUB_SHA"

build:
needs: prepare
if: needs.prepare.outputs.release == 'true'
uses: ./.github/workflows/build.yml
with:
source-ref: ${{ needs.prepare.outputs.commit }}
release-version: ${{ needs.prepare.outputs.version }}

draft:
publish:
needs: [prepare, build]
if: needs.prepare.outputs.release == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
Expand All @@ -64,11 +64,9 @@ jobs:
with:
name: pt-cli-bundle-${{ needs.build.outputs.commit }}-${{ github.run_attempt }}
path: dist/release
- name: Recheck tag and upload only an unpublished draft
- name: Tag, upload to a draft, and publish
env:
GH_TOKEN: ${{ github.token }}
PT_TAG: ${{ needs.prepare.outputs.version }}
PT_COMMIT: ${{ needs.build.outputs.commit }}
run: |
python scripts/release.py check-tag --tag "$PT_TAG" --expected-commit "$PT_COMMIT"
python scripts/release.py create-draft --repository "$GITHUB_REPOSITORY" --tag "$PT_TAG" --commit "$PT_COMMIT" --assets dist/release
PT_COMMIT: ${{ needs.prepare.outputs.commit }}
run: python scripts/release.py publish --repository "$GITHUB_REPOSITORY" --tag "$PT_TAG" --commit "$PT_COMMIT" --assets dist/release --changelog CHANGELOG.md
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Changelog

Each release has one section, headed by its exact `VERSION`. A merge to `main`
that changes `VERSION` publishes that section as the release notes; see
[docs/RELEASING.md](docs/RELEASING.md). Links inside a section are absolute,
because the notes are also shown on the release page.

## v0.4.0-alpha.1

The first published release of pt cli. Both `pt` and the compatible `ptctl`
entry point are in every package. Everything here is alpha: the commands, the
`ptctl.dev/v1` JSON schema, and the private-store formats can still change.

### What works

- **Metafiles:** strict bounded bencode, exact v1/v2/hybrid identity, and a
private exact-byte, no-clobber metafile store.
- **Content proof:** v1 piece and v2 Merkle verification, bounded discovery of
renamed or scattered bytes, and copy-only, journaled materialization.
- **TJUPT:** session, account, search, detail, and bonus reads; acknowledged
metafile fetch; at-most-once bonus exchange; and `site login` with password
and optional two-step code, saving the session cookie to an owner-only file.
- **M-Team:** session, account, search (with paging and filters), detail, own
torrent lists (seeding, leeching, completed, incomplete, uploaded), and bonus
reads; acknowledged metafile fetch and at-most-once bonus exchange through the
official API; and `site login` saving the API key.
- **Saved credentials:** after `site login`, every site command uses the saved
credential; `site logout` removes it.
- **Downloaders:** qBittorrent and Transmission reads, plus reviewed stopped
adoption, recheck/start, stop, and keep-data removal of one exact job.
- **Reconciliation:** one report that keeps site, downloader, metafile, and
storage evidence on separate axes.
- **Source retirement:** reviewed unlinking of exact source names and removal
of exact empty parents.
- **Automation:** `--output json` on every command, stable exit codes, stdin-only
secrets, and explicit `--acknowledge-*` flags for every effect; see
[docs/AUTOMATION.md](https://github.com/tonycoder-hub/ptctl/blob/v0.4.0-alpha.1/docs/AUTOMATION.md).

### Known limits

- M-Team metafile fetch and bonus exchange pass offline tests but were not run
against a real torrent or exchange. M-Team messages and RSS are not supported.
- A TJUPT session cookie expires; run `site login` again when a read reports
the session is no longer authenticated.
- Concurrent `pt` processes do not share a request rate limit; run site
commands one at a time.
- Packages exist for Windows amd64, Linux amd64, and macOS arm64 only, and are
not code-signed or notarized.
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ before artifact upload; the final assembly checks that all three targets agree
on version and commit. CI and release calls share `.github/workflows/build.yml`.
The release controls have standard-library regression tests:
`python -B -m unittest discover -s scripts/tests -v`.
See [RELEASING.md](docs/RELEASING.md) for version/tag rules and draft-only delivery.
See [RELEASING.md](docs/RELEASING.md) for VERSION and CHANGELOG rules and the
merge-triggered release.
For a local snapshot, inject `cli.Version` and `cli.Commit` with the same `-X`
linker flags used by CI, then run the acceptance script with the two binaries
and matching `--version` / `--commit` values. Mark uncommitted builds as local
Expand Down
39 changes: 21 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ For an extracted macOS/Linux package, run `sh examples/readonly/try.sh` for an
offline walkthrough. Discover the core commands with `pt torrent --help`,
`pt help client list`, and `pt help config`.

> Status: `v0.4.0-alpha` development. Ordinary inspection, downloader reads,
> content proof, discovery, planning, and reconciliation are intentionally
> Status: `v0.4.0-alpha.1`, an alpha release. Ordinary inspection, downloader
> reads, content proof, discovery, planning, and reconciliation are intentionally
> zero-write. Persistent writes and tracker-visible effects are confined to
> explicit store/index commands and separately acknowledged operations; see
> [write boundaries](#write-boundaries) and the full
Expand Down Expand Up @@ -55,7 +55,7 @@ capabilities at the edge, not assumptions in the core domain model.
and password login with an optional two-step code that issues the session
cookie;
and an experimental M-Team adapter with session, account, search, detail,
and bonus reads plus acknowledged metafile fetch and at-most-once bonus
own-torrent-list, and bonus reads plus acknowledged metafile fetch and at-most-once bonus
exchange through the official API and a site-issued API key.
- **Downloaders:** qBittorrent and Transmission reads, plus reviewed stopped
adoption, recheck/start, stop, and keep-data removal of one exact job.
Expand Down Expand Up @@ -83,29 +83,32 @@ Run `ptctl help` for the exact flags of every command.

## Install

Preview packages for Windows amd64, Linux amd64, and macOS arm64 are built by
CI after tests and extracted-binary acceptance. Download the
`pt-cli-bundle-<commit>-<attempt>` artifact from a successful `ci` run on
[Actions](https://github.com/tonycoder-hub/ptctl/actions) (artifacts expire
after 14 days), then follow the
Packages for Windows amd64, Linux amd64, and macOS arm64 are on
[Releases](https://github.com/tonycoder-hub/ptctl/releases), with
`SHA256SUMS` and `release-manifest.json`; follow the
[checksum and extraction steps](docs/READ_ONLY_QUICKSTART.md). Each package
contains both commands, the short guide, synthetic samples, licenses, build
identity, and SHA-256 checksums. Packages are not code-signed or notarized.
What changed in each release is in [CHANGELOG.md](CHANGELOG.md). Preview
packages of any commit are the `pt-cli-bundle-<commit>-<attempt>` artifact of
a successful `ci` run on
[Actions](https://github.com/tonycoder-hub/ptctl/actions) (artifacts expire
after 14 days).

To build from source you need Go 1.24 or newer. The published tags predate the
current code, so install from `main`:
To build from source you need Go 1.24 or newer:

```bash
go install github.com/tonycoder-hub/ptctl/cmd/pt@main
go install github.com/tonycoder-hub/ptctl/cmd/ptctl@main # optional compatible name
go install github.com/tonycoder-hub/ptctl/cmd/pt@v0.4.0-alpha.1
go install github.com/tonycoder-hub/ptctl/cmd/ptctl@v0.4.0-alpha.1 # optional compatible name
```

Source builds report `dev` / `unknown` from `pt version`. CI stamps both
commands with `<VERSION>+g<commit-prefix>` and the full commit (on pull
requests, the tested merge commit). Maintainers stage releases with the
[release procedure](docs/RELEASING.md): it builds an existing version tag and
only ever creates an unpublished draft. See [CONTRIBUTING.md](CONTRIBUTING.md)
for local checks and synthetic binary acceptance.
Use `@main` instead for unreleased changes. Source builds report `dev` /
`unknown` from `pt version`. CI stamps both commands with
`<VERSION>+g<commit-prefix>` and the full commit (on pull requests, the tested
merge commit). A merge to `main` that changes `VERSION` publishes that version;
see the [release procedure](docs/RELEASING.md). See
[CONTRIBUTING.md](CONTRIBUTING.md) for local checks and synthetic binary
acceptance.

## Five-minute start

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.4.0-alpha
v0.4.0-alpha.1
7 changes: 4 additions & 3 deletions docs/ADDING_A_SITE.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ constant, a port interface, and one entry there.
| `bonus.offer.review` | `BonusReviewReader` | config and session | `site bonus review` |
| `bonus.exchange.submit_effectful` | `BonusExchangeWriter` | config and session | `site bonus exchange prepare`, `submit` |
| `auth.login_effectful` | `SessionLoginer` | login | `site login` |
| `account.torrents.read` | `AccountTorrentLister` | direct | `site torrents` |

### Direct ports

Expand Down Expand Up @@ -209,7 +210,7 @@ change: add it to the allowlist and to the CLI tests in the same commit.

## Public failure causes

Ordinary reads (`status`, `account`, `search`, `bonus-catalog`) fold every
Ordinary reads (`status`, `account`, `search`, `torrents`, `bonus-catalog`) fold every
adapter error into `site CMD failed`, so an adapter's own error text never
reaches the user. An adapter may wrap one of the sentinels in
`internal/site/errors.go` to let the CLI name a fixed, secret-free cause:
Expand Down Expand Up @@ -269,7 +270,7 @@ and do it in a separate behavior-preserving commit.
| NexusPHP forks, including TJUPT | Cookie sessions match `cookie_header`, and HTML responses match the existing ports. | Page recognition and parsers for that fork, with synthetic fixtures. Forks differ, so do not assume TJUPT's pages. |
| Unit3D | Cookie-session web pages fit. | Using its token-authenticated API instead runs into the gaps below. |
| Gazelle-based trackers | Cookie sessions fit; their JSON responses need a JSON parser rather than HTML recognition. | Where an API key replaces the session cookie, the gaps below apply. |
| M-Team | Status, account, search, detail, the bonus shop catalog, review, and exchange, the signed-link metafile download, and live-site reconciliation are implemented in `internal/site/mteam` over the JSON API with an API key. | RSS, seeding lists, and messages are not implemented. |
| M-Team | Status, account, search, detail, the account's own torrent lists, the bonus shop catalog, review, and exchange, the signed-link metafile download, and live-site reconciliation are implemented in `internal/site/mteam` over the JSON API with an API key. | Messages need a browser login the API key cannot replace, and RSS links are rotating secrets; neither is implemented. |

## Gaps for API-token sites

Expand All @@ -282,7 +283,7 @@ or a security control, so it needs its own review.
| Gap | Status | Where | What is left |
|---|---|---|---|
| Only one auth method existed | Done | `domain.AuthMethodAPIKeyHeader` (`api_key_header`); `knownAuthMethod` in `internal/site/descriptor.go` | Nothing. |
| Credential input was cookie-only | Done | `--api-key-stdin` and `readAPIKeyCredential` in `internal/cli` serve `site status`, `account`, `search`, `detail`, `bonus-catalog`, and `bonus review`; `site metafile fetch` and `site bonus exchange submit` read it with `readEffectfulAPIKeyCredential`; `reconcile` takes `--site-api-key-stdin`, `--site-live`, and the bundle's `site_api_key` | Nothing. The `--credential-bundle-stdin` of `site bonus exchange submit` still carries a cookie, because only TJUPT confirms an exchange with the password. |
| Credential input was cookie-only | Done | `--api-key-stdin` and `readAPIKeyCredential` in `internal/cli` serve `site status`, `account`, `search`, `torrents`, `detail`, `bonus-catalog`, and `bonus review`; `site metafile fetch` and `site bonus exchange submit` read it with `readEffectfulAPIKeyCredential`; `reconcile` takes `--site-api-key-stdin`, `--site-live`, and the bundle's `site_api_key` | Nothing. The `--credential-bundle-stdin` of `site bonus exchange submit` still carries a cookie, because only TJUPT confirms an exchange with the password. |
| The CLI gated on cookies | Done | Every site command picks the method with `siteCredentialSourceFor` and checks that the site supports it | Nothing. |
| The transport only sent `Cookie` | Done | `httpguard.NewWithHeaderCredential` binds one validated, non-reserved header | Nothing. |
| Redaction did not know the header | Done | `security.Redact` covers `x-api-key` header lines and `apiKey`-style fields | Nothing. |
Expand Down
4 changes: 3 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ internal/reconcile

internal/site
optional AuthChecker / AccountReader / TorrentSearcher /
BonusCatalogReader / BonusReviewReader ports and a capability-gated
BonusCatalogReader / BonusReviewReader / AccountTorrentLister ports and
a capability-gated
effectful metafile port
|-- httpguard the only HTTP client site adapters use
|-- mteam M-Team JSON API reads with an API key
Expand Down Expand Up @@ -356,6 +357,7 @@ Capabilities are small and explicit:
- `bonus.offer.review`
- `bonus.exchange.submit_effectful`
- `auth.login_effectful`
- `account.torrents.read`

`auth.login_effectful` (`site.SessionLoginer`) signs in with an account
password and optional one-time code, typed at hidden terminal prompts or read
Expand Down
4 changes: 2 additions & 2 deletions docs/AUTOMATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Every JSON result is a single object on stdout, indented with two spaces:
| Area | Kinds |
|---|---|
| General | `version` |
| Site reads | `site.descriptor.list` (`site list`, `site capabilities`), `site.session`, `site.account`, `site.torrent.list`, `site.torrent.detail`, `site.bonus.catalog`, `site.bonus.offer_review` |
| Site login | `site.login` |
| Site reads | `site.descriptor.list` (`site list`, `site capabilities`), `site.session`, `site.account`, `site.torrent.list`, `site.torrent.detail`, `site.account.torrent.list` (`site torrents`), `site.bonus.catalog`, `site.bonus.offer_review` |
| Site login | `site.login`, `site.logout` |
| Bonus exchange | `site.bonus.exchange.prepare`, `site.bonus.exchange.submit`, `site.bonus.exchange.status`, `site.bonus.exchange.operation_list`, `site.bonus.exchange.prune`, `site.bonus.exchange.forget` |
| Site metafiles | `site.metafile.fetch`, `site.metafile.binding.list`, `site.metafile.binding.inspect` |
| Metafiles | `metafile.manifest` (`torrent inspect`), `content.verification` (`torrent verify`), `metafile.store.init`, `metafile.store.import`, `metafile.store.inspect` |
Expand Down
9 changes: 6 additions & 3 deletions docs/FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,12 @@ deliberately does not. For step-by-step usage, see the
- an experimental M-Team session check, account snapshot (username, uploaded
and downloaded bytes, ratio, and bonus), torrent search by page, mode,
category, and free promotion with seeders, leechers, promotion factors, and
category names, torrent detail for one remote ID, and a bonus-shop catalog
and exact-goods review, through read-only POSTs to the official JSON API (one
per invocation; the catalog reads the balance and the shop on one client),
category names, torrent detail for one remote ID, the account's own
seeding, leeching, completed, incomplete, and uploaded torrent lists with
each row's traffic scope, and a bonus-shop catalog and exact-goods review,
through read-only POSTs to the official JSON API (one per invocation; the
torrent lists read the account ID and the list, and the catalog the balance
and the shop, on one client),
authenticated by a site-issued API key saved by `site login` or piped on
stdin, with no redirect, proxy, or retry;
- an explicitly acknowledged M-Team metafile fetch for one remote ID: one
Expand Down
Loading
Loading