diff --git a/.github/WRITING.md b/.github/WRITING.md index 18f2a39..5ce7baa 100644 --- a/.github/WRITING.md +++ b/.github/WRITING.md @@ -1,82 +1,50 @@ # Writing -This guide governs documentation, user-facing text, comments, Markdown, -commit messages, changelogs, and release notes. [CONTRIBUTING.md](CONTRIBUTING.md) -governs development workflow. - -Consult Microsoft's -[PowerShell-Docs style guide](https://learn.microsoft.com/en-us/powershell/scripting/community/contributing/powershell-style-guide?view=powershell-7.6) -and [Markdown best practices](https://learn.microsoft.com/en-us/powershell/scripting/community/contributing/general-markdown?view=powershell-7.6) -for PowerShell examples and markup. This guide's conventions take precedence -where they differ. - -## Voice - -Lead with the conclusion or observable behavior, then give the evidence or -constraints needed to understand it. Use active voice, present tense, concrete -nouns, and short sentences. Assume no shared conversation history; explain -what a referenced ticket or decision means rather than relying on its ID. - -State facts rather than praising them. Replace vague claims such as "robust" -or "optimized" with the handled failure or measured improvement. Remove -filler, promotional language, emoji, agent attribution, and tool metadata. - -Use "libtmux for PowerShell" in prose and titles. Reserve `LibTmux` and -`LibTmux.PowerShell` for their module, type, and assembly identifiers. Write -PowerShell, tmux, server, session, window, and pane consistently. - -## Documentation and examples - -Document what exists. Distinguish a scaffold, an implemented capability, a -tested capability, and a published release. Do not advertise planned cmdlets -as available or copy compatibility promises from another port. - -Explain the reader's task before APIs or flags. State prerequisites, -defaults, errors, side effects, ownership, ordering, and concurrency when -they affect the contract. Do not repeat signatures or language basics. - -Examples must match available APIs and include required setup and cleanup. -When executable examples exist, prefer quoting their tested source over -maintaining a second copy. A performance claim needs a measurement and a -reproduction command. Link to the source of a rule instead of copying it -across documents. +Repository-specific rules for documentation, help text, comments, changelogs, +and commits in libtmux for PowerShell. Shared organization voice, CommonMark +wrapping, code-fence formatting, source-comment gates, slop prevention, and +commit conventions live in [`libtmux/.github` `WRITING.md`][org-writing]; +development workflow lives in [CONTRIBUTING.md](CONTRIBUTING.md). + +Consult Microsoft's [PowerShell-Docs style guide][ps-style] and +[Markdown best practices][ps-markdown] for PowerShell examples and markup; this +guide and the shared organization guide take precedence where they differ. + +## Terminology and documentation + +Use "libtmux for PowerShell" in prose and titles. Reserve `LibTmux`, +`LibTmux.Workspace`, `LibTmux.PowerShell`, and `LibTmux.Workspace.PowerShell` +for module, type, and assembly identifiers. Write PowerShell, `tmux`, `server`, +`session`, `window`, and `pane` consistently. + +Document what exists: distinguish a scaffold, an implemented capability, a +tested capability, and a published release, and do not advertise planned +cmdlets or copy compatibility claims from another port. State prerequisites, +defaults, errors, side effects, ownership, ordering, and concurrency when they +affect the caller contract. Prefer quoting tested source over maintaining a +second copy, and attach every performance figure to its reproduction command. ## Comments and errors -Keep comments that explain a non-obvious invariant, protocol constraint, -platform workaround, ordering requirement, or failure mode. Prefer one or -two direct lines. Preserve tool directives and comments that explain code -which appears wrong but is required. - -Remove narration of the next lines, duplicated names or defaults, -speculative future work, and history already held by Git. Put rejected -alternatives and the reasoning behind a change in its commit message. - -Error messages name the failed operation and concrete cause. Include a -useful next action when one exists; omit empty phrases such as "an error -occurred". +Follow the Loss, Ceiling, and Upkeep gates in +[`libtmux/.github` `WRITING.md`][org-comments]: keep one or two lines for a +non-obvious invariant, protocol or `tmux` version constraint, ordering rule, or +code that looks wrong but is intentional, and preserve analyzer directives. +Error messages name the failed operation, the concrete cause, and a useful next +action when one exists. ## Markdown -Use plain CommonMark with descriptive sentence-case headings. Put a blank -line before lists and after headings. Wrap repository prose at 80 columns -where practical; do not break URLs, identifiers, or tables to meet the width. -Do not hard-wrap GitHub issue or pull request paragraphs. - -Avoid personal information, machine-specific paths, brittle line references, -bare commit hashes, and counts that duplicate source state. +Follow [`libtmux/.github` `WRITING.md`][org-commonmark] for plain CommonMark +(no GitHub alert markers in repository `.md` files), 80-column prose wrapping, +and unwrapped GitHub issue and pull request bodies. ### Code blocks -Code blocks are paste-and-run units: - -- Put one command in each block. An explicit `&&`, `;`, or `\` continuation - counts as one command. -- Put explanations in prose above the block, not comments inside it. -- Mark shell commands as `console` and prefix them with `$ `. -- Split long commands with `\`, one flag per continuation line. -- Use the actual language tag for source examples. Keep executed examples - valid for their runner. +Follow [`libtmux/.github` `WRITING.md`][org-code-blocks]: keep one paste-and-run +command per `console` fence with a `$ ` prompt (`\` continuations, one flag per +line) and prose explanations above the fence. Use `powershell` on PowerShell +source fences and keep executed examples valid for their runner. ## Examples @@ -168,77 +136,44 @@ Good, name the value first: ## README shape -A README reads at a glance: tasks, the API for each, and an example. The root -README and each module README follow this shape. - -- **Header:** the logo block, a centred title, the badge row (CI, PowerShell - Gallery version, libtmux.org, license) and one sentence, all as Markdown - inside the centred block. A badge or link points at a page that exists; a - package with no Gallery page gets no badge. -- **Sections:** a `##` heading names a task in the reader's words, such as - "Find sessions, windows, and panes". -- **API headings:** a `###` heading names a cmdlet or type as a link to its - libtmux.org reference page, then a colon and its job in plain words. -- **Under a heading:** a line or two that link sibling APIs, the example, what - it prints, at most one short note, and a More link to the guide. -- **Length:** no paragraph over three lines. A list of facts is a bullet list. - The README links test fails a paragraph or list item over 240 characters. -- **No inventory:** do not list features. Sections and examples show them. -- **Floors:** state requirements as floors a reader can act on, such as "tmux - 3.3a or newer". Leave out toolchain patch versions, CI matrix narration and - kernel details, and link the compatibility guide. -- **Assumed facts:** do not say that examples are tested, how docs are built or - what the checks cover. -- **Packages:** keep the table. Give each module one heading that links its - directory on the trunk branch, a one-line description and a link line for the - reference, the Gallery page and the changelog. A product with no published - package gets no page, link or section. -- **Closing:** "What it leaves out" and "Support and status" are short bullets - with a bold lead. -- **Imports first:** the first example in each README section starts with its - `Import-Module` line. -- **Own server:** an example starts its server through `New-TmuxServer` on a - unique socket and cleans up through the cmdlets, not with `tmux` shell - commands. -- **Run in CI:** every displayed example is a copy of a region of - `examples/Guides.ps1`, or a script under `examples/`, that the guide tests - run. -- **Headline features:** the root README shows the query and filter cmdlets, the - query plan, command chains and control-mode clients and events, each under an - API heading with an example, or links the guide's complete tested program. +The root `README.md` and each module `README.md` follow the shared +[`libtmux/.github` `README shape`][org-readme-shape] with these PowerShell +specifics: + +- **Header and install:** the logo block, centred title, badge row (CI, + PowerShell Gallery version when published, `libtmux.org`, license), and + one-sentence summary inside the centred block, followed by Gallery install + commands, runtime floors (`PowerShell 7.4 or newer`, `tmux 3.3a or newer`), + and a checkout pointer ahead of or within `Quick start`. +- **Tasks and linked APIs:** `##` task headings and `###` headings linking each + cmdlet or native type on `libtmux.org`. `tests/ReadmeLinks.Tests.ps1` fails on + unlinked first API mentions, broken anchors, or any paragraph or list item + over 240 rendered characters. +- **Examples:** start each section's first example with `Import-Module`, use + `New-TmuxServer` on a unique socket with cmdlet cleanup (never shell `tmux`), + and copy every displayed `powershell` fence from `examples/Guides.ps1` or + `examples/`. +- **Headline features:** show query and filter cmdlets, `Get-TmuxQueryPlan`, + command chains, and control-mode clients and events (or link the tested guide + program). +- **Packages and closing:** keep the package table and per-module trunk + headings linking the reference, Gallery page, and module changelog, then + close with `What it leaves out`, `Support and status`, compact reference + links, and the `libtmux.org` family line. ## Commit messages -Use `Scope(type[detail]): Description`. The detail qualifier is optional. -Name the affected component and use an imperative, capitalized description -without a trailing period. Keep subjects within 50 characters and body -lines within 72, except indivisible URLs or identifiers. - -Use `docs` for documentation, `chore` for configuration, and `rules[AGENTS]` -or `rules[CLAUDE]` under the `Ai` scope for agent entry points. Use `feat`, -`fix`, `refactor`, `test`, `style`, or `ci` when they describe the change. - -A small, self-explanatory change can use a subject alone. For a change that -needs a body, explain the reason in a `why:` paragraph, then list the -concrete changes under `what:`. Separate those sections with a blank line. -Use a heredoc or message file to preserve newlines. - -Keep each commit focused on one logical change. Do not add emoji, tool -signatures, attribution trailers, or pull request numbers to ordinary -commits. Keep intermediate attempts and rejected approaches in commit -history when they explain a decision, not in product documentation. +Follow the `Scope(type[detail]): Description` format, 50/72 limits, and `why:` +/ `what:` body in [`libtmux/.github` `WRITING.md`][org-commits]. Use `docs`, +`chore`, `feat`, `fix`, `refactor`, `test`, `style`, or `ci`, and use +`Ai(rules[AGENTS])` or `Ai(rules[CLAUDE])` for agent entry points. ## Pull requests, changelogs, and releases -Describe the final change for someone who has not read the conversation. -Lead with the problem and resulting behavior, then give relevant validation -and limits. Name the checks that ran and distinguish passing, failing, -skipped, and unverified work. - -When a changelog exists, record caller-visible changes under its unreleased -section. State changed defaults and incompatibilities with migration -guidance. Do not invent versions or release dates. Mention old behavior only -when users of a published release experienced it. +Follow [`libtmux/.github` `WRITING.md`][org-commits] for pull requests and +release notes. Report the checks run and distinguish passing, failing, skipped, +and unverified work. Record caller-visible changes and migration guidance under +the unreleased changelog section without inventing versions or dates. Each module keeps its own `CHANGELOG.md` in its `module/` directory, which the build copies into the package: `module/LibTmux/CHANGELOG.md` for `LibTmux` and @@ -253,6 +188,11 @@ The unreleased heading of every file is dated at the release. A module's that ships none. When the first entry lands in a release that says ``No entries for `LibTmux`.``, delete that line. -Release notes explain why an upgrader should care and what action is needed. -Link the detailed changelog instead of repeating it. Internal refactors and -branch history belong in commits unless they affect users. +[org-writing]: https://github.com/libtmux/.github/blob/main/WRITING.md +[org-commonmark]: https://github.com/libtmux/.github/blob/main/WRITING.md#commonmark +[org-code-blocks]: https://github.com/libtmux/.github/blob/main/WRITING.md#code-blocks +[org-readme-shape]: https://github.com/libtmux/.github/blob/main/WRITING.md#readme-shape +[org-comments]: https://github.com/libtmux/.github/blob/main/WRITING.md#source-comments +[org-commits]: https://github.com/libtmux/.github/blob/main/WRITING.md#commits-and-pull-requests +[ps-style]: https://learn.microsoft.com/en-us/powershell/scripting/community/contributing/powershell-style-guide?view=powershell-7.6 +[ps-markdown]: https://learn.microsoft.com/en-us/powershell/scripting/community/contributing/general-markdown?view=powershell-7.6 diff --git a/README.md b/README.md index 1014785..0fa0fa3 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,22 @@ objects that a pipeline can filter. -Needs PowerShell 7.4 or newer and tmux 3.3a or newer, on Linux or WSL. Some -cmdlets need a newer tmux; [compatibility](docs/compatibility.md) lists them. +Install [`LibTmux`](https://www.powershellgallery.com/packages/LibTmux/) from +the PowerShell Gallery with PowerShell 7.4 or newer and tmux 3.3a or newer on +Linux or WSL ([compatibility](docs/compatibility.md)): + +```console +$ Install-Module -Name LibTmux +``` + +Or with `PSResourceGet`: + +```console +$ Install-PSResource -Name LibTmux +``` + +For a source checkout, see [Install from source](#install-from-source) and +[CONTRIBUTING.md](.github/CONTRIBUTING.md#setup). **Contents** — [Quick start](#quick-start) · [Find things](#find-sessions-windows-and-panes) · @@ -31,27 +45,10 @@ cmdlets need a newer tmux; [compatibility](docs/compatibility.md) lists them. [Service readiness](#wait-for-service-readiness) · [Choose how to run](#choose-how-to-run) · [Workspaces](#build-a-workspace-from-a-file) · [Packages](#packages) · -[From source](#install-from-source) · [Leaves out](#what-it-leaves-out) · -[Support](#support-and-status) · [Documentation](#documentation) - -**Reference** — [Cmdlet reference](docs/reference/README.md) · -[Compatibility](docs/compatibility.md) · -[Troubleshooting](docs/troubleshooting.md) · [License](#license) +[Leaves out](#what-it-leaves-out) · [Support](#support-and-status) ## Quick start -Install the module from the PowerShell Gallery with `pwsh`: - -```console -$ Install-PSResource -Name LibTmux -``` - -Import it: - -```console -$ Import-Module -Name LibTmux -ErrorAction Stop -``` - ### [`New-TmuxServer`][new-tmuxserver]: a handle on a private server It names a socket and an empty tmux configuration, and contacts nothing, so @@ -98,6 +95,65 @@ exit status. More: [command completion](docs/input.md#run-a-command-to-completion). Later sections reuse `$server`. +### [`examples/QuickStart.ps1`](examples/QuickStart.ps1): a private server and three panes + +Run it from a checkout root to start a private server, split `editor`, add +`logs`, stop the server, and return a captured [`LibTmux.Session`][session]: + + +```powershell +(./examples/QuickStart.ps1).Windows | Select-Object Name, @{ + Name = 'PaneIds' + Expression = { $_.Panes.Id -join ', ' } +} +``` + +It prints: + +```text +Name PaneIds +---- ------- +editor %0, %1 +logs %2 +``` + +Its [`Windows`][session-windows] and [`Panes`][session-panes] stay readable +after cleanup, and your default tmux server stays untouched. + +### Install from source + +From a checkout with [mise](https://mise.jdx.dev/) tools installed +([setup](.github/CONTRIBUTING.md#setup)), restore the +[libtmux for .NET packages](https://www.nuget.org/packages/LibTmux) and build +both modules into `build/Modules`: + +```console +$ pwsh -NoLogo -NoProfile -File eng/Build.ps1 \ + -Restore +``` + +Start PowerShell with the staged module path (see +[review package builds](.github/CONTRIBUTING.md#review-package-builds) for +shared .NET changes): + +```console +$ LIBTMUX_REVIEW_MODULE_ROOT="$PWD/build/Modules" \ + pwsh \ + -NoLogo \ + -NoProfile +``` + +Import the staged manifests so an installed module cannot shadow the build: + + +```powershell +$modules = $env:LIBTMUX_REVIEW_MODULE_ROOT +Import-Module -Name @( + "$modules/LibTmux/0.1.0/LibTmux.psd1", + "$modules/LibTmux.Workspace/0.1.0/LibTmux.Workspace.psd1" +) -ErrorAction Stop +``` + ## Find sessions, windows, and panes ### [`Get-TmuxSnapshot`][get-tmuxsnapshot]: what tmux holds, in one read @@ -401,10 +457,10 @@ More: [execute an ordered chain](docs/commands.md#execute-an-ordered-chain). ### [`Connect-TmuxControl`][connect-tmuxcontrol]: one client for repeated commands -It attaches one control client. [`Invoke-TmuxControlCommand`][invoke-tmuxcontrolcommand] -sends a command through it, and -[`Disconnect-TmuxControl`][disconnect-tmuxcontrol] ends it. This example reads a -session name, then disconnects and removes its session: +It attaches one control client. +[`Invoke-TmuxControlCommand`][invoke-tmuxcontrolcommand] sends a command +through it, and [`Disconnect-TmuxControl`][disconnect-tmuxcontrol] ends it. +This example reads a session name, then disconnects and removes its session: ```powershell @@ -579,80 +635,6 @@ Reference: [every LibTmux.Workspace cmdlet][workspace-module], [PowerShell Gallery](https://www.powershellgallery.com/packages/LibTmux.Workspace), [changelog](module/LibTmux.Workspace/CHANGELOG.md). -## Install from source - -Install PowerShell and the .NET SDK from [.tool-versions](.tool-versions) with -[mise](https://mise.jdx.dev/): - -```console -$ mise install -``` - -Install tmux with your package manager and check that it is on `PATH`: - -```console -$ tmux -V -``` - -From the checkout root, restore the -[libtmux for .NET packages](https://www.nuget.org/packages/LibTmux) and build -both modules: - -```console -$ pwsh -NoLogo -NoProfile -File eng/Build.ps1 \ - -Restore -``` - -The build stages both modules under `build/Modules`. For shared .NET changes, -see [review package builds](.github/CONTRIBUTING.md#review-package-builds). -Start PowerShell with the staged module path: - -```console -$ LIBTMUX_REVIEW_MODULE_ROOT="$PWD/build/Modules" \ - pwsh \ - -NoLogo \ - -NoProfile -``` - -Import the staged manifests so an installed module cannot shadow the build: - - -```powershell -$modules = $env:LIBTMUX_REVIEW_MODULE_ROOT -Import-Module -Name @( - "$modules/LibTmux/0.1.0/LibTmux.psd1", - "$modules/LibTmux.Workspace/0.1.0/LibTmux.Workspace.psd1" -) -ErrorAction Stop -``` - -### [`examples/QuickStart.ps1`](examples/QuickStart.ps1): a private server and three panes - -Run it from the checkout root. It starts a private server, splits the `editor` -window, adds `logs`, stops the server, and returns a captured -[`LibTmux.Session`][session]. Show each window's pane IDs: - - -```powershell -(./examples/QuickStart.ps1).Windows | Select-Object Name, @{ - Name = 'PaneIds' - Expression = { $_.Panes.Id -join ', ' } -} -``` - -It prints: - -```text -Name PaneIds ----- ------- -editor %0, %1 -logs %2 -``` - -Assign the script's output to a variable to keep the session. Its -[`Windows`][session-windows] and [`Panes`][session-panes] stay readable after -the script removes its session. It uses a unique socket, so your default tmux -server stays untouched. - ## What it leaves out - **Live objects.** A captured object keeps what tmux said when you read it. @@ -680,46 +662,20 @@ server stays untouched. The cmdlets return its native objects and add parameter binding, help, formatting and `-WhatIf` / `-Confirm`. -## Documentation - -- **Read:** [snapshots and filtering](docs/read.md), [structured queries](docs/query.md), - [pane contents and scrollback](docs/capture.md), [attached clients](docs/clients.md). -- **Automate:** [create](docs/create.md), [send text and keys](docs/input.md), - [arrange and resize](docs/layout.md), [link and move windows](docs/placement.md), - [remove sessions, windows and panes](docs/remove.md). -- **Configure:** [options](docs/options.md) with [`Set-TmuxOption`][set-tmuxoption], - [hooks](docs/hooks.md) with [`Set-TmuxHook`][set-tmuxhook], - [environment for new panes](docs/environment.md). -- **Coordinate:** [chains and control clients](docs/commands.md), - [event streams, jobs and parallel workers](docs/watch.md). -- **Workspaces:** [load, review and apply](docs/workspace.md), - [export a starting declaration](docs/workspace.md#export-a-starting-declaration), - [edit a declaration](docs/workspace.md#edit-the-declaration). - -Browse cmdlets with `Get-Command -Module LibTmux` and examples with -`Get-Help LibTmux\New-TmuxSession -Examples`. Further reading: - -- [Compatibility](docs/compatibility.md): the support contract -- [Troubleshooting](docs/troubleshooting.md): endpoint, package, input and - stream failures -- [Benchmarks](benchmarks/README.md): workloads and how to rerun them -- [Changelog](CHANGELOG.md): changes across both modules, plus - [`LibTmux`](module/LibTmux/CHANGELOG.md) and - [`LibTmux.Workspace`](module/LibTmux.Workspace/CHANGELOG.md) -- [Contributing](.github/CONTRIBUTING.md): runners and development checks -- [Example sources](examples/Guides.ps1): the code behind every block here - -## AI policy - -Use these packages with AI tools as you like. When contributing, check what you -submit and wait for a maintainer's invitation before preparing a pull request. -See the [AI policy](https://libtmux.org/en/meta/ai-policy/), also kept as -[AI_POLICY.md](https://github.com/libtmux/.github/blob/HEAD/AI_POLICY.md). - -## License - -[MIT](LICENSE). See [third-party notices](licenses/THIRD-PARTY-NOTICES.md) -for bundled dependencies. +[Documentation](https://libtmux.org/en/powershell/) · +[Cmdlet reference](docs/reference/README.md) · +[Compatibility](docs/compatibility.md) · +[Troubleshooting](docs/troubleshooting.md) · +[Benchmarks](benchmarks/README.md) · +[Changelog](CHANGELOG.md) · +[Contributing](.github/CONTRIBUTING.md) · +[AI policy](https://libtmux.org/en/meta/ai-policy/) + +Licensed under [MIT](LICENSE) +([third-party notices](licenses/THIRD-PARTY-NOTICES.md)). Part of the +[libtmux.org](https://libtmux.org/) family alongside +[Python libtmux](https://github.com/tmux-python/libtmux) and +[libtmux for .NET](https://github.com/libtmux/libtmux-dotnet). [libtmux-module]: https://libtmux.org/en/powershell/latest/reference/ [workspace-module]: https://libtmux.org/en/powershell/latest/workspace/reference/ @@ -727,8 +683,6 @@ for bundled dependencies. [new-tmuxsession]: https://libtmux.org/en/powershell/latest/reference/libtmux-new-tmuxsession/ [split-tmuxpane]: https://libtmux.org/en/powershell/latest/reference/libtmux-split-tmuxpane/ [set-tmuxpanesize]: https://libtmux.org/en/powershell/latest/reference/libtmux-set-tmuxpanesize/ -[set-tmuxoption]: https://libtmux.org/en/powershell/latest/reference/libtmux-set-tmuxoption/ -[set-tmuxhook]: https://libtmux.org/en/powershell/latest/reference/libtmux-set-tmuxhook/ [set-tmuxwindowsize]: https://libtmux.org/en/powershell/latest/reference/libtmux-set-tmuxwindowsize/ [new-tmuxwindow]: https://libtmux.org/en/powershell/latest/reference/libtmux-new-tmuxwindow/ [get-tmuxsnapshot]: https://libtmux.org/en/powershell/latest/reference/libtmux-get-tmuxsnapshot/