Commit Graph

63 Commits

Author SHA1 Message Date
Fintan Halpenny 2a47bc0c7d term: provide default HELP message
Provide a default message that informs the user of the `(e)`, `(enter)`, and
`(esc)` functionality.

Unfortunately, it is not possible to provide any message that is better
customised to each case, due to `inquire` requiring a `'a` lifetime on all its
inputs – this rules out providing any kind of `String` input.

The first paramter of `Editor::new` can already be used to provide more
contextual information. The second parameter is left configurable, but for now
`Editor::HELP` is used everywhere.
2025-07-23 10:31:15 +02:00
Fintan Halpenny a998ce691d ssh: provide path on connect error
Provide the path that is being used for connecting to the SSH agent, when an I/O
error occurs.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 8224819fed radicle/profile: Enable home detection on Windows
To avoid that users on Windows have to explcitly set `HOME`, also accept
`USERPROFILE` which is considered equivalent.

To avoid repeating to join `.radicle`, split the logic up into two
phases. Also take care to provide a good error message, as this error is
fatal and user-facing.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 1e0a14ddcf ssh: Remove dependency on log 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 8e6279a382 ssh: Remove dependency on byteorder 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 95b3303eb9 term: Remove unused dependency shlex 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 009436efac ssh: Use winpipe for SSH agent on Windows
The trait `radicle_ssh::agent::client::ClientStream` trait was
simplified, because `winpipe::WinStream` is so similar to
`std::os::unix::net::UnixStream` that we can just use the same
implementation for both platforms.

However, obtaining the process identifier of the SSH agent process is
not common on Windows, so we instead track the path that we used to
connect to the agent. This is also helpful on Unix. In some cases, the
path will even contain the process identifier. The path is printed by
`rad self`.

Errors are cleaned up, and error messages are improved.
2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 0705501537 radicle: Depend on winpipe for Windows support 2025-07-23 10:31:15 +02:00
Lorenz Leutgeb 08b535d567 radicle: Only set file limits on Unix 2025-07-23 10:31:13 +02:00
Lorenz Leutgeb e7fb5647ac term: Remove dependency on libc
Introducing the new enum `TerminalFile` to model which standard stream
stream the terminal uses allows us to remove the dependency on `libc`
which does not build on Windows.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb 70fb0d3fef term: Use inquire for spawning the editor
`radicle-term` includes quite a lot of rather "low-level" logic to spawn
the preferred editor of the user. In particular, this logic is
platform-dependent and only works on Unix-like platforms.

Also, `radicle-term` already depends on `inquire` which features an
editor prompt. It is a cross-platform solution to spawn the editor.
This commit changes the implementation of `Editor` to be a wrapper of
`inquire::Editor`, keeping the interface mostly intact.

Downsides:
 - We cannot edit a file "in place" this way, instead we have to read
   it, as `inquire` only supports editing temporary files. This can also
   be viewed as a benefit, as we lessen the risk of corruption of these
   files.
 - `inquire::Editor` contains borrows, so it is quite cumbersome to
   extend it with a custom mechanism for looking up the preferred
   editor. The lookup logic was kept, but needs to be invoked by the
   caller. In the future we might consider just using the logic provided
   by `inquire` or requesting a change to `inquire`.
 - The prompt is a bit strange. It does not show the current state of
   the output, see <https://github.com/mikaelmello/inquire/issues/280>
   and <https://github.com/mikaelmello/inquire/pull/271>.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb a28fd65e89 term/ansi: Remove unused Windows module 2025-07-23 10:30:33 +02:00
Lorenz Leutgeb d46d36ecee term/spinner: Only handle signals on Unix
The `radicle-signals` crate only supports Unix, so using it prevents
`radicle-term` to build on Windows.

Of course, this means that non-Unix platforms will not support any
signal handling at all, but at least we can build.
2025-07-23 10:30:33 +02:00
Lorenz Leutgeb 92d77f9ec3 crypto/ssh/keystore: Reduce scope of DirBuilderExt
Directory builder extensions are platform specific and only available on
Unix. Move their use into a conditionally compiled block, so that we can
build on Windows.
2025-07-23 10:30:33 +02:00
Sekhat Temporus 37ea81766e cli: improve default branch pick
When using `rad init` the default branch for the project can be predetermined by
inspecting the working copy repository.

To improve the experience, it will first check `init.defaultBranch` in the Git
configuration file.

If it does not find this, it falls back to choosing the default head of the
repository at the time. This may be HEAD, and in this case it will error and
provide helpful information.

The repository may also not have any default head at the time, and this also
results in an error and hint.
2025-07-23 07:43:27 +01:00
Tobias Hunger 7c4b71ab82 radicle: Keep pinned repos ordered in config
Do not return them in a random order in radicle-httpd,
so that we can have them in a defined order in
radicle-explorer.
2025-07-19 12:59:02 +01:00
Fintan Halpenny 1fa30e2e88 cli: test missing commits for canonical quorum
Test the scenario where 2 delegates are collaborating, where one delegate is
missing the other's commit while pushing to the default branch.
2025-07-19 12:32:45 +01:00
Fintan Halpenny afe64d5175 remote-helper: improve canonical handling
This set of changes refactors the canonical handling by isolating the business
logic into another type, `Canonical`.

The functionality remains the same, but certain error scenarios are better
handled. Primarily, the commits of the inner `Canonical` type are checked to see
if they exist in the working copy, and if not, provide a more useful message
about which commit was missing or invalid for which DID.
2025-07-19 12:32:31 +01:00
Fintan Halpenny 14444a43ea remote-helper: refactor pushing action
Reduce the nesting of if statements by using a `PushAction` enum that is
constructed by checking the `dst` reference and parsing the correct action, one
of:

- `OpenPatch`
- `UpdatePatch`
- `PushRef`

This makes the intent of the code a little bit more clear and reduces the tabbing
of big code blocks. It also captures the error specifically for handling the
parsing of this `dst` reference.
2025-07-19 10:53:51 +01:00
Tobias Hunger a9f75d47ec remote-helper: allow any revision in push src
This allows any revision that can resolve to an object. The `src` side of the
refspec is resolved to its corresponding `Oid` which is further used for remote
helper pushing and patch creation/update.

Co-authored-by: Lorenz Leutgeb <lorenz.leutgeb@radicle.xyz>
2025-07-18 22:22:43 +01:00
Tobias Hunger da72557cf7 git-remote-rad: Allow pushing from bare repositories
Bare git repositories are meant to fetch into/push from and
fetching works, but pushing from a bare repo into radicle-storage
was prohibited.

This is a problem for me as I want to use `jj`, which uses
a bare git repository in the back (when not co-located into
a "normal" git repository).
2025-07-18 22:04:07 +01:00
Lorenz Leutgeb 271ef497d7 crypto: Fix scope of `ssh-key` dependency
`radicle-crypto` is the only crate that actually depends on `ssh-key`. I
overlooked that previously and added it as a workspace dependency. Now I
am limiting its scope again.
2025-07-18 21:52:43 +01:00
Lorenz Leutgeb 0e3f3f03d2 cli: Improve formatting of Node IDs and addresses
Pay more attention to when a Node ID is displayed in compact form. As
this was sometimes used to save space, e.g. in `rad node status` in
combination with long node addresses (like .onion names), also implement
a compact format for node addresses and use that instead in some cases.
Progress notifications in spinners keep the short form.
2025-07-18 21:44:06 +01:00
Fintan Halpenny 010d5134e8 protocol: fix `Frame` docstring
The `[T]` and `[I]` are interpretted as links when running `cargo doc`. This
table is surrounded in a code fence to prevent this, but also provide a better
view of the table when rendered to HTML.
2025-07-17 08:57:50 +01:00
Lorenz Leutgeb 3c5668edd2 protocol: Reimplement encoding on top of `bytes` 2025-07-16 21:15:55 +02:00
Lorenz Leutgeb 1c20f64a26 node, protocol: Refactor
Mostly changes of `use`s and moving components to `radicle-protocol`,
with the goal of just getting `radicle-node` to work on top of the new
`radicle-protocol` crate.
2025-07-16 21:15:52 +02:00
Lorenz Leutgeb 61c468778a protocol: Create skeleton by moving from radicle-node
This commit will not build. If you are reading this while bisecting,
please skip this commit. It is not fixed to build to get clean renames.
2025-07-16 21:12:42 +02:00
Lorenz Leutgeb b9759c5868 radicle: Make `node::Link` copy and add `is_*`
This will allow us to replace `netservices::LinkDirection` with
`radicle::node::Link` in a drop-in manner.
2025-07-16 21:12:42 +02:00
Fintan Halpenny 8201225166 cli: test canonical tags
Add a test to exercise adding canonical reference rules and pushing new
canonical tags.

A change in `rad id` was required to allow adding a new payload to the document,
i.e. one that does not already exist.

Adding rules is also documented in the man page for `rad id`.
2025-07-16 16:54:43 +02:00
Fintan Halpenny ff365e2d8b radicle: disallow default branch
Ensure that the default branch is only ever synthesized from the `Doc`'s
`threshold` and `delegates` value. If the rule is ever written into a `RawDoc`,
then the update of the that `RawDoc` must go through the `update::veryify`
function, which checks that the rule is not present.
2025-07-16 16:41:16 +02:00
Fintan Halpenny a69397386a cli: extract document update logic
The business logic of modifying the identity document should not live in the CLI
code for updating said document.

Instead, we extract out that logic into separate update functions and these are
using from the CLI instead.
2025-07-16 16:41:16 +02:00
Fintan Halpenny 7f646666bc radicle: canonical references payload 2025-07-16 16:41:16 +02:00
Fintan Halpenny af6cf03acd radicle: canonical reference rules
Introduce the `rules` module beneath `canonical`. The implementation follows
the Canonical References RIP[^0].

A `Rule` defines the DIDs and threshold required to get the canonical tip
for a reference (or set of references). Since a `Rule` has some specific
validation rules, there can be two versions of a `Rule`. The `RawRule` is one
that can be easily constructed, serialized, and deserialized. It must then be
validated into a `ValidRule`, which validates any constraints, and can be used
in the computing of a canonical tip.

For convenience, a set of `ValidRule`s is wrapped into the `Rules` type, which
also has a further constraint that each rule refers to a specific `refspec`.

[0]: 1d1ce874f7
2025-07-16 16:41:16 +02:00
Fintan Halpenny fb8681f5bc radicle: `connect` returns `ConnectError`
Refactor the `connect` method to return a `ConnectError` so that it can be
reported via logging at call sites, and returned as an error from the node
handle.
2025-07-16 15:47:10 +02:00
Fintan Halpenny 29043134a3 radicle: hotfix release 0.16.1
Releasing a hotfix version for the inclusion of `ReviewEdit` and
`ReviewReaction` changes.
2025-07-15 15:18:05 +01:00
Sebastian Martinez 4e08eef8d5 radicle: add missing `review_react` methods 2025-07-15 11:37:04 +02:00
Fintan Halpenny 3a47003578 radicle: add ReviewEdit getter methods
Downstream clients require access to the data for a `ReviewEdit` – for example,
the desktop client builds a representation of `Action`s for TypeScript
generation.

To allow these kinds of use cases, methods are added to `ReviewEdit` to allow
access to its underlying data.
2025-07-15 09:55:45 +01:00
Fintan Halpenny b77809ae9d chore: prepare crates release
Prepare the crates for releasing to crates.io:
- radicle-remote-helper: 0.10 -> 0.11
- radicle-term: 0.12 -> 0.13
- radicle-cli: 0.13 -> 0.14
- radicle-node: 0.11 -> 0.12
- radicle-fetch: 0.11 -> 0.12
- radicle: 0.15 -> 0.16

It was also necessary to specify the `version` in the workspace Cargo.toml file,
since this is required for publishing to crates.io.
2025-07-14 15:38:09 +01:00
Fintan Halpenny fe6a11d0db radicle: fix schemars macro on FetchPackSizeLimit
While running `cargo-semver-checks`, there was an issue that was surfaced
regarding `serde(into)`, `serde(try_from)` and `schemars(transparent)` being
used, and they are incompatible.

This appeared to be a semver issue, on the side of `schemars`, since the issue
would only appear when adding `radicle` as a fresh dependency. The intuition for
this is that once `schemars` was updated locally, the same error appeared when
attempting to build the `radicle` crate.

To avoid this, `schemars` provides a `!` operator for the macro[^0]:

> You can also “unset” serde attributes by including them with a ! prefix in a
> schemars attribute, which will make schemars ignore the corresponding serde
> attribute item

[^0]: https://docs.rs/schemars_derive/latest/schemars_derive/derive.JsonSchema.html#attributes
2025-07-14 14:51:59 +01:00
Erik Kundt 4e429e4408 radicle: Fix doctests 2025-07-14 12:41:56 +02:00
Fintan Halpenny 34939253f7 radicle: improve reviews
The `Review::summary` was limited in behaviour, since it was only an
`Option<String>`.

The field is now changed to `NonEmpty<Edit>` so that it can enable an edit
history, as well as being able to supply embeds as part of the text.

`Reactions` are also introduced to `Review` and, necessarily, introducing an
`Action::ReviewReact`.

Note that some machinery was added under `actions` and `encoding` to enable
backwards-compatibility.
For `actions`, a new `ReviewEdit` is introduced to keep
track of the different versions of editing actions – supporting the old actions
while also introducing the new variant.
For `encoding`, the machinery exploits the fact that an `Option<String>` can be
converted into a `NonEmpty<Edit>` given that an `ActorId` and `Timestamp` are
available, and that `None` can be converted into an empty string. The struct
`patch::Review` now deserializes via this `encoding::review::Review` type and,
importantly, preserves backwards-compatibility.
2025-07-14 11:26:40 +02:00
Fintan Halpenny c30298fb8a radicle: implement std::error::Error for AnnouncerError 2025-07-09 14:40:53 +01:00
Fintan Halpenny e965d9a2c9 node: clean up `UploadError`
This change better separates the different errors that can occur during an
upload. It does this by:
- Separating the authorization error into its own enum and having a variant
  simply for that
- The `PacketLine` error was never constructed, so the error returned from the
  `upload_pack::pktline::git_request` is now wrapped in this variant.
- The error from `upload_pack::upload_pack` is now wrapped in an `UploadPack`
  variant.
- The `Io` variant is removed.
- Other redundant variants are also removed.
2025-07-09 13:11:04 +01:00
Lorenz Leutgeb 5a840983a8 node, cli: Refactor test environment 2025-07-09 11:47:50 +01:00
Fintan Halpenny 38ff2652b1 radicle: remove unnecessary constraints
The constraints on some of the `cob` related traits are unnecessary, so this
patch removes them.
2025-07-08 11:36:42 +02:00
Johannes Kühlewindt 895ca5d025 cli: rad node connect using only NodeId
Allow the `rad node connect` command to use only a `NodeId` when connecting.

The `NodeId` is used to connect to known addresses, and will stop at the first
address that is connected to.
2025-07-03 12:13:49 +01:00
Fintan Halpenny 76e00a34ea cli: change link direction symbols
The symbols used for [inbound] and [outbound] are part of the [Supplementary
Multilingual Plane](smp) (or Plane 1). This set of symbols are not as well
supported by font sets, as discovered by many reports of the characters missing.

There are two other arrow characters: [south east] and [north east] that serve
the same style and are part of the [Basic Multilingual Plane](bmp) (or Plane 0).
This set of characters is more widely supported.

[inbound]: https://www.compart.com/en/unicode/U+1F866
[outbound]: https://www.compart.com/en/unicode/U+1F865
[smp]: https://en.wikipedia.org/wiki/Plane_(Unicode)#Supplementary_Multilingual_Plane
[bmp]: https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_Multilingual_Plane
[north east]: https://www.compart.com/en/unicode/U+2197
[south east]: https://www.compart.com/en/unicode/U+2198
2025-07-02 11:10:09 +01:00
Lorenz Leutgeb 84427a56b5 radicle-term: Use crossterm instead of termion 2025-06-27 15:39:29 +02:00
Lorenz Leutgeb ee8ffcc799 radicle-term: Inline `termion::get_tty` for Unix 2025-06-27 15:39:29 +02:00
Lorenz Leutgeb ec47566cb0 radicle-term: Remove custom pager
I learned that there is an implementation of a pager in
`crates/radicle-term/src/pager.rs`. It does not make sense to me to
maintain a pager in `heartwood`, this is too far from the core of what
we are trying to achieve and adds unnecessary maintenance burden. We can
allow ourselves to defer to the paging done by `git` or just call the
user's `$PAGER`. Even though falling back to unpaged output might not be
the nicest thing, I still prefer that over maintaining the pager.

It also was frustrating to me that the pager does not support things
like search (like `less` does).

This also significantly decreases our dependence on `termion`.

The pager was originally implemented by cloudhead in

  40f4383bbc

and integrated into `rad diff` in

  6dd52c94fb

This commit restores the behaviour introduced in

  84a95848b0

(before there was a custom pager implementation).
2025-06-27 15:35:19 +02:00