From 1601955b364a4740a8874166e730e3d0b8784ae5 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 27 Oct 2026 17:09:42 -0500 Subject: [PATCH 1/4] docs(ports[go]) Install the homepage example from the v0.1.0 release why: The Go homepage example still fetched libtmux-go at an unreleased revision, required v0.0.0 with a replace line and listed Git as a prerequisite, while the Go MCP and workspace pages already install v0.1.0 from the Go proxy. The v0.1.0 quickstart is also a different program from the one at that revision, so editing go.mod alone would have left the displayed code unverified. Its socket name is fixed, so the views that drop the deferred Server.Kill failed a second run with a session called "demo" already present. what: - Require libtmux-go v0.1.0 in the displayed go.mod with no replace line, set up with go mod tidy and go build, and drop Git from the prerequisites. - Rebuild the program from examples/quickstart/main.go at v0.1.0, which runs a command with Session.Run and prints its output and exit status. Two long calls are wrapped to fit 80 columns. The concise, errors and cleanup views keep their roles: neither error context nor cleanup, error context only, and cleanup only. - Put the process ID in the socket name in every view, as the other ports' homepage programs name a socket per run, so the views that leave their server running can be run again. Keeping Server.Kill in every view would make the Cleanup option change nothing. - Point the receipt at c21afc69 (tree 827524d3), rehash all four views and record the tmux versions that ran: 3.3a, 3.7c and 3.8. tmux 3.2a is below the 0.1.0 floor and the library refuses it. - Native runs: scripts/check-example-prose.py --example home --port go for all four views on tmux 3.3a, 3.7c and 3.8, Go 1.26.5, with an empty module cache that downloaded libtmux-go v0.1.0 from the Go proxy. Each printed "hello from tmux" and "exit status: 0". The cleanup and full views left no server running; concise and errors leave their idle server, which the Cleanup option removes. - Each view then ran twice in a row against one isolated socket directory on tmux 3.3a and 3.8, and both runs printed the expected output. With the fixed socket name the concise and errors views failed the second run. --- site/src/data/home-examples.json | 22 +++++------ site/test/fixtures/home-examples.json | 54 ++++++++++++++------------- 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/site/src/data/home-examples.json b/site/src/data/home-examples.json index a9de965d5..b2f253e35 100644 --- a/site/src/data/home-examples.json +++ b/site/src/data/home-examples.json @@ -188,12 +188,12 @@ "go": { "lang": "go", "sourceRepository": "libtmux/libtmux-go", - "sourceRevision": "6f3df55f8a41999e41225eefb3940545b834e6a2", - "sourceTree": "96e6d6d4f688bf26503e46a541a88d6fce71663c", + "sourceRevision": "c21afc69867e989410e15b3616a8c0f0b1073c33", + "sourceTree": "827524d332b79227dd4bd82b0d99e5fc12a1156e", "program": "quickstart.go", "excerpt": { "startLine": 1, - "endLine": 116, + "endLine": 56, "dedent": 0, "importsEndLine": 0 }, @@ -201,24 +201,24 @@ { "name": "quickstart.go", "lang": "go", - "code": "package main\n\nimport (\n\t\"bufio\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc start() (err error) {\n\troot := \"/tmp/libtmux-go-test\"\n\tif err := os.MkdirAll(root, 0700); err != nil {\n\t\treturn err\n\t}\n\tdirectory, err := os.MkdirTemp(root, \"home-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tBinary: os.Getenv(\"TMUX_BIN\"),\n\t\tSocketPath: filepath.Join(directory, \"tmux.sock\"),\n\t\tConfigFile: \"/dev/null\",\n\t})\n\tif err != nil {\n\t\treturn errors.Join(err, os.RemoveAll(directory))\n\t}\n\n\tdefer func() {\n\t\tcleanup, cancel := context.WithTimeout(\n\t\t\tcontext.Background(),\n\t\t\t3*time.Second,\n\t\t)\n\t\tdefer cancel()\n\n\t\tif stopErr := server.Kill(cleanup); stopErr != nil {\n\t\t\terr = errors.Join(err, stopErr)\n\t\t\treturn // Keep the directory if cleanup fails.\n\t\t}\n\t\terr = errors.Join(err, os.RemoveAll(directory))\n\t}()\n\n\tctx, cancel := context.WithTimeout(\n\t\tcontext.Background(),\n\t\t10*time.Second,\n\t)\n\tdefer cancel()\n\n\treturn run(ctx, server)\n}\n\nfunc run(ctx context.Context, server tmux.Server) (err error) {\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"libtmux-go-quickstart\",\n\t\tWindowName: \"start\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create session: %w\", err)\n\t}\n\n\twindow, err := session.NewWindow(ctx, tmux.NewWindowRequest{\n\t\tName: new(\"work\"),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create window: %w\", err)\n\t}\n\n\tpane, err := window.SplitPane(ctx, tmux.SplitPaneRequest{\n\t\tDirection: tmux.PaneDirectionRight,\n\t\tCommand: \"sh\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"split window: %w\", err)\n\t}\n\n\toutput, err := pane.OpenObservation(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"watch pane: %w\", err)\n\t}\n\tdefer func() {\n\t\terr = errors.Join(err, output.Close())\n\t}()\n\n\t_, err = fmt.Fprintln(\n\t\tpane.Writer(ctx),\n\t\t\"printf 'libtmux ready\\\\n'\",\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"send command: %w\", err)\n\t}\n\tscanner := bufio.NewScanner(output.Reader(ctx))\n\tfor scanner.Scan() {\n\t\tif scanner.Text() == \"libtmux ready\" {\n\t\t\tfmt.Println(\"libtmux ready\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn fmt.Errorf(\"read pane: %w\", err)\n\t}\n\treturn io.ErrUnexpectedEOF\n}\n" + "code": "// Command quickstart runs a command in tmux and prints what it showed.\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := run(context.Background()); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc run(ctx context.Context) (err error) {\n\t// A private server: a socket and an empty config of its own, so this\n\t// neither touches nor is changed by a tmux you already use.\n\t// The process ID in the socket name keeps one run apart from the next.\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tSocketName: fmt.Sprintf(\"libtmux-quickstart-%d\", os.Getpid()),\n\t\tConfigFile: os.DevNull,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"configure tmux: %w\", err)\n\t}\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"demo\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create session: %w\", err)\n\t}\n\t// Cleanup runs even when ctx is the reason the program is leaving.\n\tdefer func() {\n\t\terr = errors.Join(err, server.Kill(context.WithoutCancel(ctx)))\n\t}()\n\n\t// The command runs in a window of its own, with a terminal.\n\tresult, err := session.Run(\n\t\tctx,\n\t\t\"echo hello from tmux\",\n\t\ttmux.RunOptions{},\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"run command: %w\", err)\n\t}\n\tfor _, line := range result.Lines {\n\t\tfmt.Println(line)\n\t}\n\tfmt.Println(\"exit status:\", result.Status)\n\treturn nil\n}\n" }, { "name": "go.mod", "lang": "text", - "code": "module example.com/libtmux-home\n\ngo 1.26.0\n\nrequire github.com/libtmux/libtmux-go v0.0.0\n\nreplace github.com/libtmux/libtmux-go => ./source\n" + "code": "module example.com/libtmux-home\n\ngo 1.26.0\n\nrequire github.com/libtmux/libtmux-go v0.1.0\n" } ], - "prerequisites": "POSIX shell, Git, tmux 3.3a or newer and Go 1.26.5.", + "prerequisites": "POSIX shell, tmux 3.3a or newer and Go 1.26.5.", "commands": [ - "git init -q source\ngit -C source fetch -q --depth=1 \\\n https://github.com/libtmux/libtmux-go.git \\\n 6f3df55f8a41999e41225eefb3940545b834e6a2\ngit -C source checkout -q --detach FETCH_HEAD\ngo build -p 2 -o quickstart quickstart.go", + "go mod tidy\ngo build -p 2 -o quickstart quickstart.go", "unset TMUX TMUX_PANE\nexport ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/sh\n./quickstart" ], - "expectedOutput": "libtmux ready\n", + "expectedOutput": "hello from tmux\nexit status: 0\n", "variants": { - "concise": "package main\n\nimport (\n\t\"bufio\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc start() (err error) {\n\troot := \"/tmp/libtmux-go-test\"\n\tif err := os.MkdirAll(root, 0700); err != nil {\n\t\treturn err\n\t}\n\tdirectory, err := os.MkdirTemp(root, \"home-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tBinary: os.Getenv(\"TMUX_BIN\"),\n\t\tSocketPath: filepath.Join(directory, \"tmux.sock\"),\n\t\tConfigFile: \"/dev/null\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithTimeout(\n\t\tcontext.Background(),\n\t\t10*time.Second,\n\t)\n\tdefer cancel()\n\n\treturn run(ctx, server)\n}\n\nfunc run(ctx context.Context, server tmux.Server) (err error) {\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"libtmux-go-quickstart\",\n\t\tWindowName: \"start\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twindow, err := session.NewWindow(ctx, tmux.NewWindowRequest{\n\t\tName: new(\"work\"),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpane, err := window.SplitPane(ctx, tmux.SplitPaneRequest{\n\t\tDirection: tmux.PaneDirectionRight,\n\t\tCommand: \"sh\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toutput, err := pane.OpenObservation(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\terr = errors.Join(err, output.Close())\n\t}()\n\n\t_, err = fmt.Fprintln(\n\t\tpane.Writer(ctx),\n\t\t\"printf 'libtmux ready\\\\n'\",\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tscanner := bufio.NewScanner(output.Reader(ctx))\n\tfor scanner.Scan() {\n\t\tif scanner.Text() == \"libtmux ready\" {\n\t\t\tfmt.Println(\"libtmux ready\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn err\n\t}\n\treturn io.ErrUnexpectedEOF\n}\n", - "errors": "package main\n\nimport (\n\t\"bufio\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc start() (err error) {\n\troot := \"/tmp/libtmux-go-test\"\n\tif err := os.MkdirAll(root, 0700); err != nil {\n\t\treturn err\n\t}\n\tdirectory, err := os.MkdirTemp(root, \"home-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tBinary: os.Getenv(\"TMUX_BIN\"),\n\t\tSocketPath: filepath.Join(directory, \"tmux.sock\"),\n\t\tConfigFile: \"/dev/null\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tctx, cancel := context.WithTimeout(\n\t\tcontext.Background(),\n\t\t10*time.Second,\n\t)\n\tdefer cancel()\n\n\treturn run(ctx, server)\n}\n\nfunc run(ctx context.Context, server tmux.Server) (err error) {\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"libtmux-go-quickstart\",\n\t\tWindowName: \"start\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create session: %w\", err)\n\t}\n\n\twindow, err := session.NewWindow(ctx, tmux.NewWindowRequest{\n\t\tName: new(\"work\"),\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create window: %w\", err)\n\t}\n\n\tpane, err := window.SplitPane(ctx, tmux.SplitPaneRequest{\n\t\tDirection: tmux.PaneDirectionRight,\n\t\tCommand: \"sh\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"split window: %w\", err)\n\t}\n\n\toutput, err := pane.OpenObservation(ctx)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"watch pane: %w\", err)\n\t}\n\tdefer func() {\n\t\terr = errors.Join(err, output.Close())\n\t}()\n\n\t_, err = fmt.Fprintln(\n\t\tpane.Writer(ctx),\n\t\t\"printf 'libtmux ready\\\\n'\",\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"send command: %w\", err)\n\t}\n\tscanner := bufio.NewScanner(output.Reader(ctx))\n\tfor scanner.Scan() {\n\t\tif scanner.Text() == \"libtmux ready\" {\n\t\t\tfmt.Println(\"libtmux ready\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn fmt.Errorf(\"read pane: %w\", err)\n\t}\n\treturn io.ErrUnexpectedEOF\n}\n", - "cleanup": "package main\n\nimport (\n\t\"bufio\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"time\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := start(); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc start() (err error) {\n\troot := \"/tmp/libtmux-go-test\"\n\tif err := os.MkdirAll(root, 0700); err != nil {\n\t\treturn err\n\t}\n\tdirectory, err := os.MkdirTemp(root, \"home-\")\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tBinary: os.Getenv(\"TMUX_BIN\"),\n\t\tSocketPath: filepath.Join(directory, \"tmux.sock\"),\n\t\tConfigFile: \"/dev/null\",\n\t})\n\tif err != nil {\n\t\treturn errors.Join(err, os.RemoveAll(directory))\n\t}\n\n\tdefer func() {\n\t\tcleanup, cancel := context.WithTimeout(\n\t\t\tcontext.Background(),\n\t\t\t3*time.Second,\n\t\t)\n\t\tdefer cancel()\n\n\t\tif stopErr := server.Kill(cleanup); stopErr != nil {\n\t\t\terr = errors.Join(err, stopErr)\n\t\t\treturn // Keep the directory if cleanup fails.\n\t\t}\n\t\terr = errors.Join(err, os.RemoveAll(directory))\n\t}()\n\n\tctx, cancel := context.WithTimeout(\n\t\tcontext.Background(),\n\t\t10*time.Second,\n\t)\n\tdefer cancel()\n\n\treturn run(ctx, server)\n}\n\nfunc run(ctx context.Context, server tmux.Server) (err error) {\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"libtmux-go-quickstart\",\n\t\tWindowName: \"start\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\twindow, err := session.NewWindow(ctx, tmux.NewWindowRequest{\n\t\tName: new(\"work\"),\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tpane, err := window.SplitPane(ctx, tmux.SplitPaneRequest{\n\t\tDirection: tmux.PaneDirectionRight,\n\t\tCommand: \"sh\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\toutput, err := pane.OpenObservation(ctx)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer func() {\n\t\terr = errors.Join(err, output.Close())\n\t}()\n\n\t_, err = fmt.Fprintln(\n\t\tpane.Writer(ctx),\n\t\t\"printf 'libtmux ready\\\\n'\",\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tscanner := bufio.NewScanner(output.Reader(ctx))\n\tfor scanner.Scan() {\n\t\tif scanner.Text() == \"libtmux ready\" {\n\t\t\tfmt.Println(\"libtmux ready\")\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn err\n\t}\n\treturn io.ErrUnexpectedEOF\n}\n" + "concise": "// Command quickstart runs a command in tmux and prints what it showed.\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := run(context.Background()); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc run(ctx context.Context) error {\n\t// A private server: a socket and an empty config of its own, so this\n\t// neither touches nor is changed by a tmux you already use.\n\t// The process ID in the socket name keeps one run apart from the next.\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tSocketName: fmt.Sprintf(\"libtmux-quickstart-%d\", os.Getpid()),\n\t\tConfigFile: os.DevNull,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"demo\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// The command runs in a window of its own, with a terminal.\n\tresult, err := session.Run(\n\t\tctx,\n\t\t\"echo hello from tmux\",\n\t\ttmux.RunOptions{},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, line := range result.Lines {\n\t\tfmt.Println(line)\n\t}\n\tfmt.Println(\"exit status:\", result.Status)\n\treturn nil\n}\n", + "errors": "// Command quickstart runs a command in tmux and prints what it showed.\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := run(context.Background()); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc run(ctx context.Context) error {\n\t// A private server: a socket and an empty config of its own, so this\n\t// neither touches nor is changed by a tmux you already use.\n\t// The process ID in the socket name keeps one run apart from the next.\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tSocketName: fmt.Sprintf(\"libtmux-quickstart-%d\", os.Getpid()),\n\t\tConfigFile: os.DevNull,\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"configure tmux: %w\", err)\n\t}\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"demo\",\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"create session: %w\", err)\n\t}\n\n\t// The command runs in a window of its own, with a terminal.\n\tresult, err := session.Run(\n\t\tctx,\n\t\t\"echo hello from tmux\",\n\t\ttmux.RunOptions{},\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"run command: %w\", err)\n\t}\n\tfor _, line := range result.Lines {\n\t\tfmt.Println(line)\n\t}\n\tfmt.Println(\"exit status:\", result.Status)\n\treturn nil\n}\n", + "cleanup": "// Command quickstart runs a command in tmux and prints what it showed.\npackage main\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\n\t\"github.com/libtmux/libtmux-go/tmux\"\n)\n\nfunc main() {\n\tif err := run(context.Background()); err != nil {\n\t\tlog.Fatal(err)\n\t}\n}\n\nfunc run(ctx context.Context) (err error) {\n\t// A private server: a socket and an empty config of its own, so this\n\t// neither touches nor is changed by a tmux you already use.\n\t// The process ID in the socket name keeps one run apart from the next.\n\tserver, err := tmux.NewServer(tmux.ServerOptions{\n\t\tSocketName: fmt.Sprintf(\"libtmux-quickstart-%d\", os.Getpid()),\n\t\tConfigFile: os.DevNull,\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\tsession, err := server.NewSession(ctx, tmux.NewSessionRequest{\n\t\tName: \"demo\",\n\t})\n\tif err != nil {\n\t\treturn err\n\t}\n\t// Cleanup runs even when ctx is the reason the program is leaving.\n\tdefer func() {\n\t\terr = errors.Join(err, server.Kill(context.WithoutCancel(ctx)))\n\t}()\n\n\t// The command runs in a window of its own, with a terminal.\n\tresult, err := session.Run(\n\t\tctx,\n\t\t\"echo hello from tmux\",\n\t\ttmux.RunOptions{},\n\t)\n\tif err != nil {\n\t\treturn err\n\t}\n\tfor _, line := range result.Lines {\n\t\tfmt.Println(line)\n\t}\n\tfmt.Println(\"exit status:\", result.Status)\n\treturn nil\n}\n" } }, "java": { diff --git a/site/test/fixtures/home-examples.json b/site/test/fixtures/home-examples.json index 501f24254..6af1d0dca 100644 --- a/site/test/fixtures/home-examples.json +++ b/site/test/fixtures/home-examples.json @@ -430,80 +430,82 @@ "port": "go", "page": "home", "sourceRepository": "libtmux/libtmux-go", - "sourceRevision": "6f3df55f8a41999e41225eefb3940545b834e6a2", - "sourceTree": "96e6d6d4f688bf26503e46a541a88d6fce71663c", + "sourceRevision": "c21afc69867e989410e15b3616a8c0f0b1073c33", + "sourceTree": "827524d332b79227dd4bd82b0d99e5fc12a1156e", "files": [ { "name": "quickstart.go", - "sha256": "85addf0cc79c3ca1f77bda2b34c0d0ca434f34cdb7fd750639426bd635a8d503", - "clipboardSha256": "d2e7591ed34f2327708e04ec106f2d1ef0436fe3c676d6e6872e5755cf8cd101" + "sha256": "c51b65a6e41f6c87c15a2285b855152da03c3746895d04f287636872861b5d22", + "clipboardSha256": "9118bd7e00ca0ba049e7d60b11cd039c25dde81845bd51bcc2c91cb6db8bcbac" }, { "name": "go.mod", - "sha256": "c26c608d0f6c9df7d32357b0596e66ee5129f70ddacb6b85208c3c8afb2715bc", - "clipboardSha256": "89f4e696c56b6072d58a587880e7bd471cc8d35fd88f0cb61b2132896c88d83a" + "sha256": "20c363066c251c11cd573bf3616d53b394e6c9f2299190325a8b98533cb0452a", + "clipboardSha256": "19fc58b8672ca13cf69e6217bd2c85a55eddc2b65fbb84d001c5666516f6259e" } ], "shellRecipe": [ - "git init -q source\ngit -C source fetch -q --depth=1 \\\n https://github.com/libtmux/libtmux-go.git \\\n 6f3df55f8a41999e41225eefb3940545b834e6a2\ngit -C source checkout -q --detach FETCH_HEAD\ngo build -p 2 -o quickstart quickstart.go", + "go mod tidy\ngo build -p 2 -o quickstart quickstart.go", "unset TMUX TMUX_PANE\nexport ENV=/dev/null BASH_ENV=/dev/null SHELL=/bin/sh\n./quickstart" ], "expectedOutputs": [ [], [ - "libtmux ready" + "hello from tmux", + "exit status: 0" ] ], - "excerptSha256": "d2e7591ed34f2327708e04ec106f2d1ef0436fe3c676d6e6872e5755cf8cd101", + "excerptSha256": "9118bd7e00ca0ba049e7d60b11cd039c25dde81845bd51bcc2c91cb6db8bcbac", "tmuxVersions": [ - "3.2a", - "3.7c" + "3.3a", + "3.7c", + "3.8" ], "variants": { "concise": { "files": [ { "name": "quickstart.go", - "sha256": "8bc0d2eff603953dea98027efe89e3f5f65d3a4a723b2b29646711843e4d7ae9", - "clipboardSha256": "ed5db7fb3044eaac4bfc29c23476c3a7d4d8ca1cf81002a116be1b9d02785caa" + "sha256": "83541f3d63a31d9b1f7a779139aaa081fd6e5810ccc3fbf33d05092cbacbd499", + "clipboardSha256": "fa77d71de25d9ffa18a791b8fca7223076b0ddbf46f72ca5ae045e6d0f6db269" }, { "name": "go.mod", - "sha256": "c26c608d0f6c9df7d32357b0596e66ee5129f70ddacb6b85208c3c8afb2715bc", - "clipboardSha256": "89f4e696c56b6072d58a587880e7bd471cc8d35fd88f0cb61b2132896c88d83a" + "sha256": "20c363066c251c11cd573bf3616d53b394e6c9f2299190325a8b98533cb0452a", + "clipboardSha256": "19fc58b8672ca13cf69e6217bd2c85a55eddc2b65fbb84d001c5666516f6259e" } ], - "excerptSha256": "ed5db7fb3044eaac4bfc29c23476c3a7d4d8ca1cf81002a116be1b9d02785caa" + "excerptSha256": "fa77d71de25d9ffa18a791b8fca7223076b0ddbf46f72ca5ae045e6d0f6db269" }, "errors": { "files": [ { "name": "quickstart.go", - "sha256": "7804fb33e014497593f5b632c9ce0c452b5b2dbbcd596b5597068ebe0ea11e72", - "clipboardSha256": "664687296a8b5f04d823e873d8e99857825c8f999efb0506606304c3c6bc4a27" + "sha256": "df42c02a9e33c8213629978b8eeb42a523f791b09b2c6b3c22ea33f6c24cdb45", + "clipboardSha256": "f4f7369f21ed20711f16e7269bbe9ad3ec92a6dbf820e9629f508051a201a1ce" }, { "name": "go.mod", - "sha256": "c26c608d0f6c9df7d32357b0596e66ee5129f70ddacb6b85208c3c8afb2715bc", - "clipboardSha256": "89f4e696c56b6072d58a587880e7bd471cc8d35fd88f0cb61b2132896c88d83a" + "sha256": "20c363066c251c11cd573bf3616d53b394e6c9f2299190325a8b98533cb0452a", + "clipboardSha256": "19fc58b8672ca13cf69e6217bd2c85a55eddc2b65fbb84d001c5666516f6259e" } ], - "excerptSha256": "664687296a8b5f04d823e873d8e99857825c8f999efb0506606304c3c6bc4a27" + "excerptSha256": "f4f7369f21ed20711f16e7269bbe9ad3ec92a6dbf820e9629f508051a201a1ce" }, "cleanup": { "files": [ { "name": "quickstart.go", - "sha256": "91649731bbff2152b8193908653cb495ce6635a1ad00a9947ef9d1dd8634cf85", - "clipboardSha256": "2b33a9cb789e3e6aab480b41684265b10c95236f3ebff01ce145e62266d3aacc" + "sha256": "90e5ca6c3d294c515ee98f023bac290e8744b112edcf3d210c7ae46c2dc6519b", + "clipboardSha256": "88dbbc3bc8be0a0048d18dac69c14069b6717698998076dec602e51ee256d7d1" }, { "name": "go.mod", - "sha256": "c26c608d0f6c9df7d32357b0596e66ee5129f70ddacb6b85208c3c8afb2715bc", - "clipboardSha256": "89f4e696c56b6072d58a587880e7bd471cc8d35fd88f0cb61b2132896c88d83a" + "sha256": "20c363066c251c11cd573bf3616d53b394e6c9f2299190325a8b98533cb0452a", + "clipboardSha256": "19fc58b8672ca13cf69e6217bd2c85a55eddc2b65fbb84d001c5666516f6259e" } ], - "excerptSha256": "2b33a9cb789e3e6aab480b41684265b10c95236f3ebff01ce145e62266d3aacc" + "excerptSha256": "88dbbc3bc8be0a0048d18dac69c14069b6717698998076dec602e51ee256d7d1" } } }, From 8a8bc5eeb08804b1293b01a35894c5cbe70ce0b8 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 27 Oct 2026 17:10:11 -0500 Subject: [PATCH 2/4] docs(ports[elixir]) Say what the attaching guide's ~> 0.1 accepts why: The guide called "~> 0.1" the released 0.1 series. Hex resolves that requirement as 0.1.0 up to, but not including, 1.0.0, so Mix.install also installs a later 0.x release. Mix.install has no lockfile, so the displayed output is verified only for libtmux 0.1.0. what: - Replace "the released 0.1 series" with what the requirement accepts: any release from 0.1.0 up to, but not including, 1.0.0. - Keep the requirement itself: it matches the libtmux-elixir README at v0.1.0 and the homepage example. - Native runs: scripts/check-example-prose.py --example attach --port elixir on tmux 3.3a and 3.8 (Elixir 1.20.4, OTP 29, fresh MIX_HOME, HEX_HOME and MIX_INSTALL_DIR) resolved libtmux 0.1.0 from Hex and passed. --- .../content/docs/ports/elixir/guides/attaching-to-tmux.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/site/src/content/docs/ports/elixir/guides/attaching-to-tmux.md b/site/src/content/docs/ports/elixir/guides/attaching-to-tmux.md index 7255b7677..378adb9d0 100644 --- a/site/src/content/docs/ports/elixir/guides/attaching-to-tmux.md +++ b/site/src/content/docs/ports/elixir/guides/attaching-to-tmux.md @@ -22,8 +22,9 @@ covers interactive attachment and detaching. Save the complete program as `connect.exs`. The environment variable `LIBTMUX_SOCKET_PATH` selects the existing server. The launcher below sets it -to a private socket for trying the example. The first line installs the -released 0.1 series from Hex. +to a private socket for trying the example. The first line installs libtmux +from Hex. Its requirement, `~> 0.1`, accepts any release from 0.1.0 up to, but +not including, 1.0.0. ```elixir title="connect.exs" Mix.install([{:libtmux, "~> 0.1"}]) From 736f1bd8e47cd7d89acc5f99f90fdb3ccf5ced34 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 27 Oct 2026 17:10:30 -0500 Subject: [PATCH 3/4] docs(ports[csharp]) State one tmux floor on the MCP run-command example why: The page opened with "tmux 3.3a or newer" and later said the example "needs a server at version 3.4 or later". The second floor has no "tmux" before the number, so the tmux-minimum gate saw one floor while the page stated two. The F# exemption for tmux 3.4 in the same gate was anchored on text that the C# homepage prerequisites share, so a C# line with the same phrase also passed. what: - Open the example with the one floor it needs, tmux 3.4, and say that run_shell_command stages its command in a named tmux buffer, so it refuses an earlier server such as 3.3a. - Add a tmux-minimum exemption for 3.4 scoped to that paragraph by /run_shell_command/. - Add a `within` key to the exemptions. It selects a statement by the top-level key of the JSON object that holds it, and a stale entry names it. Scope the F# exemption to the fsharp object of the homepage data instead of a phrase the C# line shares. - Add negative cases: a C# homepage line with the F# phrase fails, a 3.4 statement outside the run_shell_command paragraph fails, and a paragraph that drops its 3.4 statement leaves a stale entry. The old anchor fails the C# case. --- .../ports/csharp/mcp/examples/run-command.md | 6 +- site/test/tmux-minimum.test.ts | 80 +++++++++++++++++-- 2 files changed, 75 insertions(+), 11 deletions(-) diff --git a/site/src/content/docs/ports/csharp/mcp/examples/run-command.md b/site/src/content/docs/ports/csharp/mcp/examples/run-command.md index 2e82ec80c..a28d183b6 100644 --- a/site/src/content/docs/ports/csharp/mcp/examples/run-command.md +++ b/site/src/content/docs/ports/csharp/mcp/examples/run-command.md @@ -19,10 +19,10 @@ sessions. ## Run the example -Use the .NET 10 SDK and tmux 3.3a or newer on Linux, macOS, or WSL. The library +Use the .NET 10 SDK and tmux 3.4 or newer on Linux, macOS, or WSL. The library and tool use the same [published source revision](https://github.com/libtmux/libtmux-dotnet/tree/472c2bcfbda6735139849324cc109ad70300001e). -`run_shell_command` stages its command in a named tmux buffer, so this example -needs a server at version 3.4 or later; on 3.3a the tool refuses the request. +`run_shell_command` stages its command in a named tmux buffer, so the tool +refuses the request on an earlier server, such as 3.3a. Create an empty directory: diff --git a/site/test/tmux-minimum.test.ts b/site/test/tmux-minimum.test.ts index d1ceb9d84..62afda9d1 100644 --- a/site/test/tmux-minimum.test.ts +++ b/site/test/tmux-minimum.test.ts @@ -39,8 +39,10 @@ export const PORT_FLOORS = [ * Single statements elsewhere that name another floor on purpose, usually in * a file that speaks for several ports. `near` selects the statement by its * paragraph (its line, outside Markdown), so a wrong floor elsewhere in the - * same file still fails. An entry that matches no statement fails, so an - * exemption cannot outlive the text it covers. + * same file still fails. `within` selects a statement by the top-level key of + * the JSON object that holds it, for text that several objects share. An entry + * that matches no statement fails, so an exemption cannot outlive the text it + * covers. */ export const OTHER_FLOORS = [ { @@ -64,9 +66,15 @@ export const OTHER_FLOORS = [ { path: 'site/src/data/home-examples.json', version: '3.4', - near: /tmux 3\.4 or newer on Linux\/macOS/, + within: 'fsharp', why: 'the F# quickstart prerequisites; the quickstart runs a command in a pane, which LibTmux 0.1.0 refuses below tmux 3.4 because earlier releases act on the most recent buffer when the named one is missing', }, + { + path: 'site/src/content/docs/ports/csharp/mcp/examples/run-command.md', + version: '3.4', + near: /run_shell_command/, + why: 'the run_shell_command example; the tool stages its command in a named tmux buffer, which LibTmux 0.1.0 refuses to use below tmux 3.4', + }, { path: 'site/src/lib/ports.ts', version: '3.3', @@ -148,8 +156,8 @@ export function minimums(text: string): string[] { return scan(text).map((found) => found.version) } -interface Floor { path: string, version: string, near?: RegExp } -interface Statement { path: string, version: string, context: string } +interface Floor { path: string, version: string, near?: RegExp, within?: string } +interface Statement { path: string, version: string, context: string, owner?: string } /** The paragraph around an index in Markdown, otherwise its line. */ function around(path: string, text: string, index: number): string { @@ -159,15 +167,24 @@ function around(path: string, text: string, index: number): string { return text.slice(before < 0 ? 0 : before + separator.length, after < 0 ? text.length : after) } +/** The top-level key of the JSON object around an index, such as "fsharp". */ +function ownerOf(path: string, text: string, index: number): string | undefined { + if (!path.endsWith('.json')) return undefined + return [...text.slice(0, index).matchAll(/^ {2}"([^"]+)": \{$/gm)].at(-1)?.[1] +} + export function statementsIn(path: string, text: string): Statement[] { - return scan(text).map(({ version, index }) => ({ path, version, context: around(path, text, index) })) + return scan(text).map(({ version, index }) => ({ + path, version, context: around(path, text, index), owner: ownerOf(path, text, index), + })) } /** Statements that disagree with their floor, then entries that excuse or require nothing. */ export function mismatches(statements: Statement[], ports: Floor[], others: Floor[]): string[] { const covers = (entry: Floor, statement: Statement) => statement.version === entry.version && statement.path.startsWith(entry.path) && - (entry.near?.test(statement.context) ?? true) + (entry.near?.test(statement.context) ?? true) && + (entry.within === undefined || entry.within === statement.owner) const expected = (statement: Statement) => ports.find((port) => statement.path.startsWith(port.path))?.version ?? FLOOR const wrong = statements @@ -175,7 +192,7 @@ export function mismatches(statements: Statement[], ports: Floor[], others: Floo .map((statement) => `${statement.path}: tmux ${statement.version}, expected ${expected(statement)}`) const unused = [...ports, ...others] .filter((entry) => !statements.some((statement) => covers(entry, statement))) - .map((entry) => `stale entry: ${entry.path} names tmux ${entry.version}${entry.near ? ` near ${entry.near}` : ''}, which no statement there states`) + .map((entry) => `stale entry: ${entry.path} names tmux ${entry.version}${entry.near ? ` near ${entry.near}` : ''}${entry.within ? ` within ${entry.within}` : ''}, which no statement there states`) return [...wrong, ...unused] } @@ -298,4 +315,51 @@ describe('tmux minimum statements', () => { 'm.md: tmux 3.3, expected 3.3a', ]) }) + + it('limits a JSON exemption to the object that holds the statement', () => { + const others = [{ path: 'm.json', version: '3.4', within: 'fsharp' }] + const object = (port: string) => ` "${port}": {\n "prerequisites": "tmux 3.4 or newer on Linux/macOS"\n }` + const document = (...ports: string[]) => `{\n${ports.map(object).join(',\n')}\n}\n` + expect(mismatches(statementsIn('m.json', document('fsharp')), [], others)).toEqual([]) + expect(mismatches(statementsIn('m.json', document('csharp', 'fsharp')), [], others)).toEqual([ + 'm.json: tmux 3.4, expected 3.3a', + ]) + expect(mismatches(statementsIn('m.json', document('csharp')), [], others)).toEqual([ + 'm.json: tmux 3.4, expected 3.3a', + 'stale entry: m.json names tmux 3.4 within fsharp, which no statement there states', + ]) + }) + + /** One file against the floors that cover it, so other files' entries are not stale. */ + const checkFile = (path: string, text: string) => mismatches( + statementsIn(path, text), + PORT_FLOORS.filter((port) => path.startsWith(port.path)), + OTHER_FLOORS.filter((entry) => path.startsWith(entry.path)), + ) + + it('keeps the F# exemption off the C# homepage prerequisites', () => { + const path = 'site/src/data/home-examples.json' + const csharp = '".NET SDK 10.0.303, .NET 8 and 10 runtimes, tmux on Linux/macOS"' + const text = readFileSync(join(ROOT, path), 'utf8') + expect(text).toContain(csharp) + expect(checkFile(path, text)).toEqual([]) + const probe = text.replace(csharp, csharp.replace('tmux on', 'tmux 3.4 or newer on')) + expect(checkFile(path, probe)).toEqual([ + `${path}: tmux 3.4, expected 3.3a`, + ]) + }) + + it('limits the C# run-command exemption to its run_shell_command paragraph', () => { + const path = 'site/src/content/docs/ports/csharp/mcp/examples/run-command.md' + const text = readFileSync(join(ROOT, path), 'utf8') + expect(checkFile(path, text)).toEqual([]) + const elsewhere = `${text}\nThe server must be tmux 3.4 or newer.\n` + expect(checkFile(path, elsewhere)).toEqual([ + `${path}: tmux 3.4, expected 3.3a`, + ]) + const wrong = text.replace('tmux 3.4 or newer', 'tmux 3.3a or newer') + expect(checkFile(path, wrong)).toEqual([ + `stale entry: ${path} names tmux 3.4 near /run_shell_command/, which no statement there states`, + ]) + }) }) From 4090cdae5173f820a58be5639ab49e7e492a819c Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Tue, 27 Oct 2026 17:10:45 -0500 Subject: [PATCH 4/4] docs(ports) Record tmux tags in the Elixir, Ruby and Julia receipts why: The Elixir and Ruby homepage receipts named tmux 3.8a and the Julia receipt named 3.7d. Upstream has no tag for either: refs/heads/release_3.8a and refs/heads/release_3.7d are release branches, so a reader cannot fetch what the receipt says ran. Every other tmux version in the receipt fixtures is a tag. what: - Change tmuxVersions for the elixir and ruby entries from 3.3a and 3.8a to 3.3a and 3.8, and for the julia entry from 3.7d to 3.7c and 3.8. - Native runs: scripts/check-example-prose.py --example home for all four views of each port passed. Elixir 1.20.4 and OTP 29 with fresh MIX_HOME, HEX_HOME and MIX_INSTALL_DIR resolved libtmux 0.1.0 from Hex on tmux 3.3a and 3.8. Ruby 4.0.7 and Bundler 4.0.20 with a fresh GEM_HOME installed libtmux 0.1.0 from RubyGems on tmux 3.3a and 3.8. Julia 1.13.0 ran the libtmux-julia checkout the recipe fetches on tmux 3.7c and 3.8. --- site/test/fixtures/home-examples.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/site/test/fixtures/home-examples.json b/site/test/fixtures/home-examples.json index 6af1d0dca..e57a09f0b 100644 --- a/site/test/fixtures/home-examples.json +++ b/site/test/fixtures/home-examples.json @@ -98,7 +98,7 @@ "excerptSha256": "01a8dfb7d28e85966191445cf912045fd6435ff20805845d63282bc534898e1f", "tmuxVersions": [ "3.3a", - "3.8a" + "3.8" ], "variants": { "concise": { @@ -1311,7 +1311,8 @@ ], "excerptSha256": "fcbea45d0f895ae82f18d7b5efb5d51e074fcec65d9b4d65eb3f6102149a1e78", "tmuxVersions": [ - "3.7d" + "3.7c", + "3.8" ], "variants": { "concise": { @@ -1370,7 +1371,7 @@ "excerptSha256": "a0a04cbe7b9922255ba1f93d776ab775a5eab839c8479a4d25c57801b4a6769d", "tmuxVersions": [ "3.3a", - "3.8a" + "3.8" ], "variants": { "concise": {