summaryrefslogtreecommitdiff
path: root/.agents/skills/pardes-9p/SKILL.md
blob: 4a1ddeb3358372a6ab40a1de6991eb2052354e13 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
name: pardes-9p
description: Inspect and drive a running Pardes editor through its 9P control filesystem, or exercise its panes, builtins, terminal input and rendered output in an isolated session. Use for Pardes interaction, plugin development and end-to-end debugging.
---

# Pardes over 9P

Pardes is files: `cat`, `echo >`, `ls` and shell scripts are the whole
interface. The recipes are in the Scripting chapter
([docs/typ/scripting.typ](../../../docs/typ/scripting.typ)), every file's
semantics in the Reference chapter
([docs/typ/reference.typ](../../../docs/typ/reference.typ)), and a running
session serves a summary at `$m/README`. Paths are relative to the
repository root.

## Find the session

```sh
[ -n "$NINE_MOUNT" ] || echo 'no 9P mount: use the Python client below'
s=${PARDES_9P##*/pardes-9p-}; m=$NINE_MOUNT/pardes/${s%.sock}
cat "$m/index"
```

`$NINE_MOUNT` is set by `9ns --mntgen` (usually `/mnt/9p`). `$PARDES_9P` is
the session socket of the pane you run in, `$PARDES_PANE` that pane's
serial. Under `9ns --unix SOCK -- cmd` the session is the mount itself:
`m=$NINE_MOUNT`. In a `Tty9p` shell: `m=$PARDES_MOUNT`. A dead session's
entry answers `Input/output error`: name the session, never glob. Without a
mount, plan9port's `9p -a "unix!$PARDES_9P"` works, and `test/ninep.py` in the source tree (Reference, "Other ways in").

## Traps

- A refused write says only `Invalid argument` or `Input/output error`;
  `grep '^err' $m/log | tail -1` says why. Not the log's last line: after
  a refused Del, Exit or Restore that may be `+Unsaved`'s `new`.
- Work through a pane of your own (`n=$(cat $m/pane/new)`) and its own
  `look` and `exec`: the root's act at the active pane, which another
  client, an idle shell or an event helper may own.
- `head` on `index`, `layout`, `log` or `recent` through 9ns says `Illegal
  seek`: use `sed -n 1p`. In `index`, `term` is a shell, `cmd` a command's
  pane.
- `addr` is the pane's and moves on: each `/re/` searches from the last
  address, and a `data` write leaves it just past the text. Write `addr`
  before each replacement; a failed address leaves none.
- An Edit `x` that matches nothing succeeds: check the text afterwards.
- Each open of `pane/new` makes a pane: read it once.
- Through a mount, `printf 'a\nb\n' > ctl` arrives one write per line: send
  a block as one write (`cat block > $p/ctl`), ending in a newline.
- Pane words (`Save`, `Undo`, `Del`) go to `pane/<n>/ctl`, settings and
  session words to `$m/ctl`.
- `Exit`, `Restore`, `Del` and `get` refuse once over unsaved text.
- Never experiment on a session someone is using: strip every `PARDES_*`
  variable and start your own (Scripting, "An isolated session"); build
  with `-Dplatform=tty`, since a bare `zig build` installs over
  `~/.local/bin`.