Skip to content
Open
Changes from 1 commit
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
91 changes: 91 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Repository Guidelines

## Dos and Don’ts

- Do export `LAZARUS_DIR` before running `make` or `lazbuild`; builds fail when Lazarus is not discoverable.
- Do keep `.pas` and `.lfm` changes synchronized through Lazarus; update `lang/transgui.template` plus locale files together.
- Do run only the CI steps relevant to touched files, mirroring the commands in `.travis.yml`.
- Don’t edit generated artifacts such as `Makefile` or commit outputs under `Release/`.
- Don’t modify third-party sources in `synapse/` or bundled libraries in `setup/win/openssl/` unless you are porting an upstream fix.

## Project Structure and Module Organization

Transmission Remote GUI is a Lazarus/Free Pascal desktop client for Transmission’s RPC API.

- `transgui.lpi`, `transgui.lpr`, and the root `.pas`/`.lfm` pairs implement the application UI and logic.
- `lang/` contains key-value locale files; `transgui.template` is the canonical English resource.
- `synapse/` bundles the Synapse networking library; treat it as vendor code.
- `setup/` hosts packaging assets for Unix, macOS, and Windows builds (e.g., `unix/build.sh`, `macosx/create_app_new.sh`, `win/make_zipdist.bat`).
- `snap/` stores `snapcraft.yaml` and the desktop entry used for Snap builds.
- `.github/workflows/` and `.travis.yml` define automation; `VERSION.txt`, `history.txt`, and the various README files document releases.

## Build, Test, and Development Commands

Install Lazarus (≥2.2.6) and FPC (≥3.2.2); most scripts assume `lazbuild` is on PATH or pointed to by `LAZARUS_DIR`.
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 'Core workflow' commands are Linux-specific (hard-coded /usr/lib/lazarus path and use of nproc) but are presented as generic. Please label them as Linux-only or provide macOS/Windows equivalents (e.g., avoid hard-coding LAZARUS_DIR, and replace -j$(nproc) with platform-appropriate alternatives or omit -j).

Copilot uses AI. Check for mistakes.


### Core workflow

- `cat VERSION.txt` shows the release number consumed by build scripts.
- `./setup/unix/debian-ubuntu-install_deps.sh` installs Debian/Ubuntu prerequisites (requires sudo and network access).
- `LAZARUS_DIR=/usr/lib/lazarus/default/ lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) all` builds the desktop binary without packaging; expect `transgui` (or `transgui.exe`) in the repository root.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) zipdist` builds the Linux zip bundle into `Release/`.
Comment on lines +30 to +32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The example path /usr/lib/lazarus/default/ for LAZARUS_DIR is specific to a particular Linux distribution and setup. To make these examples more generic and to reinforce the instruction from the "Dos and Don'ts" section, consider using a placeholder path. This will make it clearer to users that they need to provide their own path to the Lazarus installation.

Suggested change
- `LAZARUS_DIR=/usr/lib/lazarus/default/ lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) all` builds the desktop binary without packaging; expect `transgui` (or `transgui.exe`) in the repository root.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) zipdist` builds the Linux zip bundle into `Release/`.
- `LAZARUS_DIR=/path/to/your/lazarus/installation lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `LAZARUS_DIR=/path/to/your/lazarus/installation make -j$(nproc) all` builds the desktop binary without packaging; expect `transgui` (or `transgui.exe`) in the repository root.
- `LAZARUS_DIR=/path/to/your/lazarus/installation make -j$(nproc) zipdist` builds the Linux zip bundle into `Release/`.

- `./setup/unix/build.sh` produces compressed txz releases and temporarily rewrites `about.lfm`; the script restores the backup at the end.
- `make clean` (with `LAZARUS_DIR` set) removes generated objects after a build.

Comment on lines +29 to +35
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 'Core workflow' commands are Linux-specific (hard-coded /usr/lib/lazarus path and use of nproc) but are presented as generic. Please label them as Linux-only or provide macOS/Windows equivalents (e.g., avoid hard-coding LAZARUS_DIR, and replace -j$(nproc) with platform-appropriate alternatives or omit -j).

Suggested change
- `./setup/unix/debian-ubuntu-install_deps.sh` installs Debian/Ubuntu prerequisites (requires sudo and network access).
- `LAZARUS_DIR=/usr/lib/lazarus/default/ lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) all` builds the desktop binary without packaging; expect `transgui` (or `transgui.exe`) in the repository root.
- `LAZARUS_DIR=/usr/lib/lazarus/default/ make -j$(nproc) zipdist` builds the Linux zip bundle into `Release/`.
- `./setup/unix/build.sh` produces compressed txz releases and temporarily rewrites `about.lfm`; the script restores the backup at the end.
- `make clean` (with `LAZARUS_DIR` set) removes generated objects after a build.
#### Linux
- `./setup/unix/debian-ubuntu-install_deps.sh` installs Debian/Ubuntu prerequisites (requires sudo and network access).
- `export LAZARUS_DIR=/usr/lib/lazarus/default/` (or set to your Lazarus installation path).
- `lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `make -j$(nproc) all` builds the desktop binary without packaging; expect `transgui` in the repository root.
- `make -j$(nproc) zipdist` builds the Linux zip bundle into `Release/`.
- `./setup/unix/build.sh` produces compressed txz releases and temporarily rewrites `about.lfm`; the script restores the backup at the end.
- `make clean` removes generated objects after a build.
#### macOS
- `export LAZARUS_DIR=/Library/Lazarus/` (or set to your Lazarus installation path).
- `lazbuild -B transgui.lpi` regenerates Lazarus resources before compiling.
- `make all` builds the desktop binary; expect `transgui` in the repository root.
- `setup/macosx/create_app_new.sh [/Library/Lazarus/]` emits a signed DMG and resets `about.lfm` afterward.
- `make clean` removes generated objects after a build.
#### Windows
- Set `LAZARUS_DIR` to your Lazarus installation path.
- Use `lazbuild -B transgui.lpi` to regenerate Lazarus resources before compiling.
- Use `make all` to build the desktop binary; expect `transgui.exe` in the repository root.
- `setup/win/make_zipdist.bat <lazarus_dir>` creates the Windows portable zip and optionally compresses `transgui.exe` with UPX.
- `setup/win/make_setup.bat <lazarus_dir> "<Inno Setup dir>"` builds the Windows installer, honoring an optional `CODECERT` for signing.
- `setup/win/install_deps.bat` bootstraps Chocolatey-based dependencies (run in an elevated Windows shell).
- `make clean` removes generated objects after a build.

Copilot uses AI. Check for mistakes.

### Platform packaging

- `setup/win/make_zipdist.bat <lazarus_dir>` creates the Windows portable zip and optionally compresses `transgui.exe` with UPX.
- `setup/win/make_setup.bat <lazarus_dir> "<Inno Setup dir>"` builds the Windows installer, honoring an optional `CODECERT` for signing.
- `setup/win/install_deps.bat` bootstraps Chocolatey-based dependencies (run in an elevated Windows shell).
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompt for AI agents
Address the following comment on AGENTS.md at line 40:

<comment></comment>

<file context>
@@ -0,0 +1,91 @@
+
+- `setup/win/make_zipdist.bat &lt;lazarus_dir&gt;` creates the Windows portable zip and optionally compresses `transgui.exe` with UPX.
+- `setup/win/make_setup.bat &lt;lazarus_dir&gt; &quot;&lt;Inno Setup dir&gt;&quot;` builds the Windows installer, honoring an optional `CODECERT` for signing.
+- `setup/win/install_deps.bat` bootstraps Chocolatey-based dependencies (run in an elevated Windows shell).
+- `setup/macosx/create_app_new.sh [/Library/Lazarus/]` emits a signed DMG and resets `about.lfm` afterward.
+- `snapcraft` (run from the repository root) packages the app using `snap/snapcraft.yaml`.
</file context>

✅ Addressed in 2d710e6

- `setup/macosx/create_app_new.sh [/Library/Lazarus/]` emits a signed DMG and resets `about.lfm` afterward.
- `snapcraft` (run from the repository root) packages the app using `snap/snapcraft.yaml`.

### Static checks

- `docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:3.4.0 shfmt -sr -i 2 -l -w -ci .` formats shell scripts like the Travis job.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of -it in the docker run command is for interactive sessions. For automation and CI/CD pipelines, it's generally better to run containers in a non-interactive mode. Using -it can sometimes cause issues or hang a script if it's expecting input. I suggest removing it to make the command more robust for automation.

Suggested change
- `docker run -it --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:3.4.0 shfmt -sr -i 2 -l -w -ci .` formats shell scripts like the Travis job.
- `docker run --rm -v "$(pwd)":/sh -w /sh peterdavehello/shfmt:3.4.0 shfmt -sr -i 2 -l -w -ci .` formats shell scripts like the Travis job.

- `find . -type f -name "*.sh" -print0 | xargs -0 shellcheck` runs ShellCheck on all shell scripts.
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShellCheck command doesn’t match CI. Align doc with .travis.yml to avoid confusion.

Prompt for AI agents
Address the following comment on AGENTS.md at line 47:

<comment>ShellCheck command doesn’t match CI. Align doc with .travis.yml to avoid confusion.</comment>

<file context>
@@ -0,0 +1,91 @@
+### Static checks
+
+- `docker run -it --rm -v &quot;$(pwd)&quot;:/sh -w /sh peterdavehello/shfmt:3.4.0 shfmt -sr -i 2 -l -w -ci .` formats shell scripts like the Travis job.
+- `find . -type f -name &quot;*.sh&quot; -print0 | xargs -0 shellcheck` runs ShellCheck on all shell scripts.
+- `npx markdown-link-check README.md` validates README links after documentation edits.
+- `npx eclint check lang/ setup/ Makefile* *.txt` enforces `.editorconfig` on templated assets.
</file context>

✅ Addressed in 7102c1e

- `npx markdown-link-check README.md` validates README links after documentation edits.
Copy link

@cubic-dev-ai cubic-dev-ai bot Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markdown-link-check scope differs from CI. Update to reflect actual CI behavior.

Prompt for AI agents
Address the following comment on AGENTS.md at line 48:

<comment>markdown-link-check scope differs from CI. Update to reflect actual CI behavior.</comment>

<file context>
@@ -0,0 +1,91 @@
+
+- `docker run -it --rm -v &quot;$(pwd)&quot;:/sh -w /sh peterdavehello/shfmt:3.4.0 shfmt -sr -i 2 -l -w -ci .` formats shell scripts like the Travis job.
+- `find . -type f -name &quot;*.sh&quot; -print0 | xargs -0 shellcheck` runs ShellCheck on all shell scripts.
+- `npx markdown-link-check README.md` validates README links after documentation edits.
+- `npx eclint check lang/ setup/ Makefile* *.txt` enforces `.editorconfig` on templated assets.
+- `doctoc --title &quot;## Table of Contents&quot; --github README.md` refreshes the README ToC; rerun until the diff is clean.
</file context>
Suggested change
- `npx markdown-link-check README.md` validates README links after documentation edits.
- `find . -type f -name "*.md" | xargs -n 1 npx markdown-link-check` validates links in all Markdown files.

✅ Addressed in 39562b2

- `npx eclint check lang/ setup/ Makefile* *.txt` enforces `.editorconfig` on templated assets.
- `doctoc --title "## Table of Contents" --github README.md` refreshes the README ToC; rerun until the diff is clean.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This document is quite comprehensive and would benefit from a Table of Contents for easier navigation. You could extend the doctoc command to generate a ToC for AGENTS.md as well, similar to how it's done for README.md.

Suggested change
- `doctoc --title "## Table of Contents" --github README.md` refreshes the README ToC; rerun until the diff is clean.
- `doctoc --title "## Table of Contents" --github README.md AGENTS.md` refreshes the ToC in Markdown files; rerun until the diff is clean.


## Coding Style and Naming Conventions

- `.editorconfig` enforces UTF-8, LF endings (CRLF for `.txt`/`.bat`), and two-space indentation for Pascal, Lazarus project files, and shell scripts.
- Pascal units stay in `{$mode objfpc}{$H+}`; form classes follow the `T<Name>Form` naming pattern and expect matching `.lfm` changes.
- Use English for code comments; multi-line comments typically use `{ ... }` blocks, with `//` for inline notes.
- Locale files keep quoted key/value pairs and placeholder ordering; translate via `lang/transgui.template` to maintain consistency.
- Shell scripts preserve the existing shebang plus `set -ex`; prefer POSIX constructs to keep Travis checks green.
- Do not edit `Makefile`; modify `Makefile.fpc` or Lazarus project settings if build options need to change.

## Testing Guidelines

- No automated Pascal tests are present; perform manual regression on features affected (torrent list, dialogs, localization paths).
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This statement about "No automated Pascal tests are present" could become outdated if tests are added in the future. Consider rephrasing to "Currently no automated Pascal tests are present" or similar to indicate this is the current state.

Suggested change
- No automated Pascal tests are present; perform manual regression on features affected (torrent list, dialogs, localization paths).
- Currently, no automated Pascal tests are present; perform manual regression on features affected (torrent list, dialogs, localization paths).

Copilot uses AI. Check for mistakes.

- For core behavior changes, run the app against a test Transmission daemon (local or remote) and confirm basic flows (add/start/stop torrents, refresh list).
- Record which static checks from `.travis.yml` were run locally; execute only those relevant to the files you touched.
- When packaging scripts change, run the corresponding script in an isolated environment and verify the artifact names (`Release/transgui-<ver>-*.{zip,txz,dmg}`).
- For locale updates, launch the app with that locale to confirm formatting, placeholders, and traditional Chinese typography where applicable.
- Document manual verification steps in the PR description to aid reviewers.

## Commit and Pull Request Guidelines

- Write imperative, capitalized subjects (e.g., `Fix RPC boolean handling`); append issue numbers in parentheses when closing tickets.
- Keep changes focused; separate localization refreshes, packaging tweaks, and code fixes into discrete commits.
- Ensure CI jobs (Travis static checks, GitHub workflows) pass; mention any skipped jobs and why.
- Update `history.txt` and README variants only when user-facing behavior shifts; keep Markdown Table of Contents in sync via `doctoc`.
- Provide screenshots or recordings for UI-affecting changes, especially when adjusting forms or translations.

## Safety and Permissions

- Allowed: inspect files, adjust Lazarus form pairs tied to your change, and run targeted lint/build commands with `LAZARUS_DIR` set.
- Ask before adding dependencies, renaming units, deleting locales, or altering packaging pipelines in `setup/` and `snap/`.
- Never commit build artifacts under `Release/`, temporary files produced by `build.sh`, or personal signing material.
- Restore generated backups (`about.lfm.bak`, etc.) and verify `git status` is clean before committing.
- Treat credentials and API tokens referenced in workflows as secrets; do not hardcode or log them.

## Packaging and Distribution

- Linux releases rely on `Makefile.fpc` plus `setup/unix/build.sh`; keep widgetset and CPU flags aligned with the existing scripts.
- Windows deliverables use `setup/win/setup.iss` and bundled OpenSSL DLLs (`setup/win/openssl/`); refresh both when upgrading TLS libraries.
- macOS builds depend on `setup/macosx/create_app_new.sh`, `Info.plist`, and `transgui.icns`; verify metadata placeholders resolve correctly.
- Snap packages follow `snap/snapcraft.yaml` and `snap/local/transgui.desktop`; update them whenever assets move or new permissions are needed.