Skip to content

Commit 7dfacd3

Browse files
committed
docs(prompts): markdown syntax highlighting for sample renders; single backticks in prompt text
- Change all sample render fences from text to markdown for syntax highlighting - Add python language hint to the send_keys/wait_for_channel code block - Convert RST double backticks to single markdown backticks in prompt text (recipes.py) and matching sample renders (prompts.md) — the output is markdown sent to LLMs, not RST
1 parent a706f2f commit 7dfacd3

2 files changed

Lines changed: 50 additions & 50 deletions

File tree

docs/tools/prompts.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ channel is signalled — strictly cheaper in agent turns than a
4747

4848
**Sample render** (``command="pytest"``, ``pane_id="%1"``):
4949

50-
````text
50+
````markdown
5151
Run this shell command in tmux pane %1 and block
5252
until it finishes, preserving the command's exit status:
5353

54-
```
54+
```python
5555
send_keys(
5656
pane_id='%1',
5757
keys='pytest; __mcp_status=$?; tmux wait-for -S libtmux_mcp_wait_<uuid>; exit $__mcp_status',
@@ -61,8 +61,8 @@ capture_pane(pane_id='%1', max_lines=100)
6161
```
6262

6363
After the channel signals, read the last ~100 lines to verify the
64-
command's behaviour. Do NOT use a ``capture_pane`` retry loop —
65-
``wait_for_channel`` is strictly cheaper in agent turns.
64+
command's behaviour. Do NOT use a `capture_pane` retry loop —
65+
`wait_for_channel` is strictly cheaper in agent turns.
6666
````
6767

6868
The ``__mcp_status=$?`` capture and ``exit $__mcp_status`` mean the
@@ -91,12 +91,12 @@ the agent from acting before it has a hypothesis, which prevents
9191

9292
**Sample render** (``pane_id="%1"``):
9393

94-
```text
94+
```markdown
9595
Something went wrong in tmux pane %1. Diagnose it:
9696

97-
1. Call ``snapshot_pane(pane_id="%1")`` to get content,
97+
1. Call `snapshot_pane(pane_id="%1")` to get content,
9898
cursor position, pane mode, and scroll state in one call.
99-
2. If the content looks truncated, re-call with ``max_lines=None``.
99+
2. If the content looks truncated, re-call with `max_lines=None`.
100100
3. Identify the last command that ran (look at the prompt line and
101101
the line above it) and the last non-empty output line.
102102
4. Propose a root cause hypothesis and a minimal command to verify
@@ -130,36 +130,36 @@ override the OS-neutral default.
130130

131131
**Sample render** (``session_name="dev"``):
132132

133-
````text
133+
````markdown
134134
Set up a 3-pane development workspace named
135135
'dev' with editor on top, a shell on the bottom-left, and
136136
a logs tail on the bottom-right:
137137

138-
1. ``create_session(session_name="dev")`` — creates the
138+
1. `create_session(session_name="dev")` — creates the
139139
session with a single pane (pane A, the editor). Capture the
140-
returned ``active_pane_id`` as ``%A``.
141-
2. ``split_window(pane_id="%A", direction="below")`` — splits off
140+
returned `active_pane_id` as `%A`.
141+
2. `split_window(pane_id="%A", direction="below")` — splits off
142142
the bottom half (pane B, the terminal). Capture the returned
143-
``pane_id`` as ``%B``.
144-
3. ``split_window(pane_id="%B", direction="right")`` — splits pane B
143+
`pane_id` as `%B`.
144+
3. `split_window(pane_id="%B", direction="right")` — splits pane B
145145
horizontally (pane C, the logs pane). Capture the returned
146-
``pane_id`` as ``%C``.
147-
4. Launch the editor and the log command via ``send_keys``:
148-
``send_keys(pane_id="%A", keys="vim")`` and
149-
``send_keys(pane_id="%C", keys='watch -n 1 date')``. Leave pane B
146+
`pane_id` as `%C`.
147+
4. Launch the editor and the log command via `send_keys`:
148+
`send_keys(pane_id="%A", keys="vim")` and
149+
`send_keys(pane_id="%C", keys='watch -n 1 date')`. Leave pane B
150150
at its fresh shell prompt — nothing needs to be sent there. No
151151
pre-launch wait is required: tmux buffers keystrokes into the
152152
pane's PTY whether or not the shell has finished drawing, so
153-
``send_keys`` immediately after ``split_window`` is safe and
153+
`send_keys` immediately after `split_window` is safe and
154154
shell-agnostic.
155155
5. Optionally confirm each program drew its UI via
156-
``wait_for_content_change(pane_id="%A", timeout=3.0)``
157-
(and similarly for ``%C``). This is a "did the screen change?"
156+
`wait_for_content_change(pane_id="%A", timeout=3.0)`
157+
(and similarly for `%C`). This is a "did the screen change?"
158158
check — it works whether the pane shows a prompt glyph, a vim
159159
splash screen, or a log tail, so no shell-specific regex is
160160
needed.
161161

162-
Use pane IDs (``%N``) for all subsequent targeting — they are stable
162+
Use pane IDs (`%N`) for all subsequent targeting — they are stable
163163
across layout changes; window renames are not.
164164
````
165165

@@ -183,18 +183,18 @@ without operator consent — by drawing a clear escalation boundary.
183183

184184
**Sample render** (``pane_id="%1"``):
185185

186-
````text
186+
````markdown
187187
Interrupt whatever is running in pane %1 and
188188
verify that control returns to the shell:
189189

190-
1. ``send_keys(pane_id="%1", keys="C-c", literal=False,
191-
enter=False)`` — tmux interprets ``C-c`` as SIGINT.
192-
2. ``wait_for_text(pane_id="%1", pattern="\$ |\# |\% ",
193-
regex=True, timeout=5.0)`` — waits for a common shell prompt
190+
1. `send_keys(pane_id="%1", keys="C-c", literal=False,
191+
enter=False)` — tmux interprets `C-c` as SIGINT.
192+
2. `wait_for_text(pane_id="%1", pattern="\$ |\# |\% ",
193+
regex=True, timeout=5.0)` — waits for a common shell prompt
194194
glyph. Adjust the pattern to match the user's shell theme.
195195
3. If the wait times out the process is ignoring SIGINT. Stop and
196196
ask the caller how to proceed — do NOT escalate automatically
197-
to ``C-\`` (SIGQUIT) or ``kill``.
197+
to `C-\` (SIGQUIT) or `kill`.
198198
````
199199

200200
The shell-prompt regex covers default bash / zsh — adjust for fish

src/libtmux_mcp/prompts/recipes.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def run_and_wait(
4646
return f"""Run this shell command in tmux pane {pane_id} and block
4747
until it finishes, preserving the command's exit status:
4848
49-
```
49+
```python
5050
send_keys(
5151
pane_id={pane_id!r},
5252
keys={shell_payload!r},
@@ -56,8 +56,8 @@ def run_and_wait(
5656
```
5757
5858
After the channel signals, read the last ~100 lines to verify the
59-
command's behaviour. Do NOT use a ``capture_pane`` retry loop —
60-
``wait_for_channel`` is strictly cheaper in agent turns.
59+
command's behaviour. Do NOT use a `capture_pane` retry loop —
60+
`wait_for_channel` is strictly cheaper in agent turns.
6161
"""
6262

6363

@@ -75,9 +75,9 @@ def diagnose_failing_pane(pane_id: str) -> str:
7575
"""
7676
return f"""Something went wrong in tmux pane {pane_id}. Diagnose it:
7777
78-
1. Call ``snapshot_pane(pane_id="{pane_id}")`` to get content,
78+
1. Call `snapshot_pane(pane_id="{pane_id}")` to get content,
7979
cursor position, pane mode, and scroll state in one call.
80-
2. If the content looks truncated, re-call with ``max_lines=None``.
80+
2. If the content looks truncated, re-call with `max_lines=None`.
8181
3. Identify the last command that ran (look at the prompt line and
8282
the line above it) and the last non-empty output line.
8383
4. Propose a root cause hypothesis and a minimal command to verify
@@ -108,31 +108,31 @@ def build_dev_workspace(
108108
{session_name!r} with editor on top, a shell on the bottom-left, and
109109
a logs tail on the bottom-right:
110110
111-
1. ``create_session(session_name="{session_name}")`` — creates the
111+
1. `create_session(session_name="{session_name}")` — creates the
112112
session with a single pane (pane A, the editor). Capture the
113-
returned ``active_pane_id`` as ``%A``.
114-
2. ``split_window(pane_id="%A", direction="below")`` — splits off
113+
returned `active_pane_id` as `%A`.
114+
2. `split_window(pane_id="%A", direction="below")` — splits off
115115
the bottom half (pane B, the terminal). Capture the returned
116-
``pane_id`` as ``%B``.
117-
3. ``split_window(pane_id="%B", direction="right")`` — splits pane B
116+
`pane_id` as `%B`.
117+
3. `split_window(pane_id="%B", direction="right")` — splits pane B
118118
horizontally (pane C, the logs pane). Capture the returned
119-
``pane_id`` as ``%C``.
120-
4. Launch the editor and the log command via ``send_keys``:
121-
``send_keys(pane_id="%A", keys="vim")`` and
122-
``send_keys(pane_id="%C", keys={log_command!r})``. Leave pane B
119+
`pane_id` as `%C`.
120+
4. Launch the editor and the log command via `send_keys`:
121+
`send_keys(pane_id="%A", keys="vim")` and
122+
`send_keys(pane_id="%C", keys={log_command!r})`. Leave pane B
123123
at its fresh shell prompt — nothing needs to be sent there. No
124124
pre-launch wait is required: tmux buffers keystrokes into the
125125
pane's PTY whether or not the shell has finished drawing, so
126-
``send_keys`` immediately after ``split_window`` is safe and
126+
`send_keys` immediately after `split_window` is safe and
127127
shell-agnostic.
128128
5. Optionally confirm each program drew its UI via
129-
``wait_for_content_change(pane_id="%A", timeout=3.0)``
130-
(and similarly for ``%C``). This is a "did the screen change?"
129+
`wait_for_content_change(pane_id="%A", timeout=3.0)`
130+
(and similarly for `%C`). This is a "did the screen change?"
131131
check — it works whether the pane shows a prompt glyph, a vim
132132
splash screen, or a log tail, so no shell-specific regex is
133133
needed.
134134
135-
Use pane IDs (``%N``) for all subsequent targeting — they are stable
135+
Use pane IDs (`%N`) for all subsequent targeting — they are stable
136136
across layout changes; window renames are not.
137137
"""
138138

@@ -153,12 +153,12 @@ def interrupt_gracefully(pane_id: str) -> str:
153153
return f"""Interrupt whatever is running in pane {pane_id} and
154154
verify that control returns to the shell:
155155
156-
1. ``send_keys(pane_id="{pane_id}", keys="C-c", literal=False,
157-
enter=False)`` — tmux interprets ``C-c`` as SIGINT.
158-
2. ``wait_for_text(pane_id="{pane_id}", pattern="\\$ |\\# |\\% ",
159-
regex=True, timeout=5.0)`` — waits for a common shell prompt
156+
1. `send_keys(pane_id="{pane_id}", keys="C-c", literal=False,
157+
enter=False)` — tmux interprets `C-c` as SIGINT.
158+
2. `wait_for_text(pane_id="{pane_id}", pattern="\\$ |\\# |\\% ",
159+
regex=True, timeout=5.0)` — waits for a common shell prompt
160160
glyph. Adjust the pattern to match the user's shell theme.
161161
3. If the wait times out the process is ignoring SIGINT. Stop and
162162
ask the caller how to proceed — do NOT escalate automatically
163-
to ``C-\\`` (SIGQUIT) or ``kill``.
163+
to `C-\\` (SIGQUIT) or `kill`.
164164
"""

0 commit comments

Comments
 (0)