pi-link 0.1.13 → 0.1.14-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +12 -9
- package/bin/pi-link.mjs +8 -2
- package/index.ts +52 -8
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ This changelog is based on the git history from `2026-03-21` (initial commit) th
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## 0.1.14-beta.0 — 2026-05-04
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`--link-name <name>` flag for link-only startup naming.** Run `pi --link-name worker` to join the link as `worker` while leaving Pi's normal session selection/resume behavior untouched. This restores link-name startup naming in a cleaner form than the previous session-coupled implementation: it sets only the pi-link identity, with hub collision handling unchanged. Use `pi-link <name>` when you want the combined session-by-name + link-name workflow. Empty or whitespace-only `--link-name` values are rejected with a clear error. The `pi-link` wrapper itself does not accept `--link-name` — its rejection message now points to either `pi-link <name>` (combined) or `pi --link-name <name>` (direct, link-only).
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- **`link-name` session entries no longer accumulate on no-op restarts.** Both `pi-link <name>` and `pi --link-name <name>` skip the append when the saved name already matches. Sessions opened and exited without any persisted activity will no longer bump `pi-link list` recency from the same-name startup alone; recency still updates on messages, tool calls, edits, and real link-name changes.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
9
21
|
## 0.1.13 — 2026-05-03
|
|
10
22
|
|
|
11
23
|
### Fixed
|
package/README.md
CHANGED
|
@@ -133,16 +133,19 @@ Every other terminal sees:
|
|
|
133
133
|
|
|
134
134
|
## Configuration
|
|
135
135
|
|
|
136
|
-
Link is **off by default**. Without `--link
|
|
136
|
+
Link is **off by default**. Without `--link`, `--link-name`, or `pi-link`, the extension is completely silent — no status bar, no connections, no warnings.
|
|
137
137
|
|
|
138
|
-
| Method
|
|
139
|
-
|
|
|
140
|
-
| `pi-link <name>`
|
|
141
|
-
| `pi --link
|
|
142
|
-
|
|
|
143
|
-
| `/link-
|
|
138
|
+
| Method | When | Auto-reconnect? |
|
|
139
|
+
| ----------------------- | ---------------------------------------------------------------- | -------------------------------- |
|
|
140
|
+
| `pi-link <name>` | Resume/create named session | Yes |
|
|
141
|
+
| `pi --link-name <name>` | Connect with a specific link name; Pi session behavior unchanged | Yes |
|
|
142
|
+
| `pi --link` | Connect on startup (random name) | Yes |
|
|
143
|
+
| `/link-connect` | Opt-in mid-session (no flag needed) | Yes |
|
|
144
|
+
| `/link-disconnect` | Opt-out mid-session | Suppressed until `/link-connect` |
|
|
144
145
|
|
|
145
|
-
|
|
146
|
+
`pi --link-name <name>` sets only the pi-link terminal name; Pi's session selection/resume runs as normal. Use this when you want a stable link identity without coupling it to a same-named session. Use `pi-link <name>` when you want the combined session-by-name + link-name workflow. The `pi-link` wrapper itself does not accept `--link-name`.
|
|
147
|
+
|
|
148
|
+
**Name precedence:** `pi --link-name` > `pi-link <name>` > saved `/link-name` > Pi session name > random `t-xxxx`.
|
|
146
149
|
|
|
147
150
|
`/link-connect` and `/link-disconnect` save their intent to the session — resume later and the connection state is restored without needing the flag. Explicit user intent takes precedence over `--link`.
|
|
148
151
|
|
|
@@ -168,7 +171,7 @@ Lookup is **scoped to the current cwd by default**; pass `--global` (`-g`) to co
|
|
|
168
171
|
|
|
169
172
|
### Discovering sessions
|
|
170
173
|
|
|
171
|
-
`pi-link list` shows pi-link sessions in the current cwd; `pi-link list --global` (or `-g`) lists them across all directories. Sorted by last activity.
|
|
174
|
+
`pi-link list` shows pi-link sessions in the current cwd; `pi-link list --global` (or `-g`) lists them across all directories. Sorted by last activity — starting a session with the same name it already has does not bump recency; only real activity (messages, tool calls, edits, name changes) does.
|
|
172
175
|
|
|
173
176
|
```
|
|
174
177
|
$ pi-link list
|
package/bin/pi-link.mjs
CHANGED
|
@@ -245,13 +245,19 @@ function rejectRenamedFlag(token) {
|
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
// Reject Pi flags that pi-link manages, plus
|
|
248
|
+
// Reject Pi flags that pi-link manages, plus --link-name (which exists at the
|
|
249
|
+
// `pi` level for link-only naming, but the wrapper's combined-mode contract
|
|
250
|
+
// conflicts with it).
|
|
249
251
|
// Runs on both the first token (so `pi-link --session foo` errors clearly) and on each
|
|
250
252
|
// flag in args (so `pi-link foo --session bar` does too).
|
|
251
253
|
function rejectManagedFlag(token) {
|
|
252
254
|
const key = token.split("=")[0];
|
|
253
255
|
if (key === "--link-name") {
|
|
254
|
-
console.error(
|
|
256
|
+
console.error(
|
|
257
|
+
"Error: --link-name is not accepted by the pi-link wrapper.\n" +
|
|
258
|
+
" Use 'pi-link <name>' for combined link+session,\n" +
|
|
259
|
+
" or run 'pi --link-name <name>' directly to set link name without session resolution.",
|
|
260
|
+
);
|
|
255
261
|
process.exit(1);
|
|
256
262
|
}
|
|
257
263
|
if (["--session", "--continue", "-c", "--resume", "-r", "--fork", "--no-session", "--session-dir"].includes(key)) {
|
package/index.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Pi Link — WebSocket-based inter-terminal communication
|
|
3
3
|
*
|
|
4
4
|
* Connects multiple Pi terminals over a local WebSocket link.
|
|
5
|
-
* Opt-in via --link flag, pi-link CLI, or /link-connect command.
|
|
5
|
+
* Opt-in via --link flag, --link-name flag, pi-link CLI, or /link-connect command.
|
|
6
6
|
* First terminal to connect becomes the hub; others join as clients.
|
|
7
7
|
* Hub loss triggers automatic promotion of a surviving client.
|
|
8
8
|
*
|
|
@@ -115,6 +115,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
115
115
|
default: false,
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
+
pi.registerFlag("link-name", {
|
|
119
|
+
description:
|
|
120
|
+
"Set the pi-link terminal name on startup (link identity only; does not affect session)",
|
|
121
|
+
type: "string",
|
|
122
|
+
});
|
|
123
|
+
|
|
118
124
|
// ── State ────────────────────────────────────────────────────────────────
|
|
119
125
|
|
|
120
126
|
let role: "hub" | "client" | "disconnected" = "disconnected";
|
|
@@ -927,18 +933,56 @@ export default function (pi: ExtensionAPI) {
|
|
|
927
933
|
ctx = _ctx;
|
|
928
934
|
currentCwd = _ctx.cwd;
|
|
929
935
|
|
|
930
|
-
// Resolve terminal name:
|
|
931
|
-
// PI_LINK_NAME
|
|
932
|
-
//
|
|
933
|
-
|
|
936
|
+
// Resolve terminal name. Precedence:
|
|
937
|
+
// --link-name flag > PI_LINK_NAME env > saved link-name > session name > random
|
|
938
|
+
//
|
|
939
|
+
// --link-name is the public CLI surface (link identity only, never touches session name).
|
|
940
|
+
// PI_LINK_NAME is the internal handoff from the `pi-link` wrapper, which DOES
|
|
941
|
+
// seed session name when absent (the wrapper's combined-mode contract).
|
|
942
|
+
// PI_LINK_NAME is consumed once and removed from process.env so spawned children don't inherit it.
|
|
943
|
+
const cliRaw = pi.getFlag("link-name");
|
|
944
|
+
let cliFlagName: string | undefined;
|
|
945
|
+
if (typeof cliRaw === "string") {
|
|
946
|
+
cliFlagName = cliRaw.trim().replace(/\s+/g, " ");
|
|
947
|
+
if (!cliFlagName) {
|
|
948
|
+
console.error("Error: --link-name requires a non-empty value.");
|
|
949
|
+
process.exit(1);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
const envRaw = process.env.PI_LINK_NAME;
|
|
934
954
|
delete process.env.PI_LINK_NAME;
|
|
935
|
-
const
|
|
955
|
+
const envFlagName = envRaw?.trim().replace(/\s+/g, " ") || undefined;
|
|
956
|
+
|
|
957
|
+
const flagName = cliFlagName ?? envFlagName;
|
|
958
|
+
const fromEnv = !cliFlagName && !!envFlagName;
|
|
936
959
|
|
|
937
960
|
if (flagName) {
|
|
938
961
|
preferredName = flagName;
|
|
939
962
|
terminalName = flagName;
|
|
940
|
-
|
|
941
|
-
if
|
|
963
|
+
|
|
964
|
+
// Skip append if the saved name already matches; persistence is needed
|
|
965
|
+
// only for first-time set or actual change. Reduces session-file growth
|
|
966
|
+
// on repeated startups (common in automation).
|
|
967
|
+
let latestSaved: string | undefined;
|
|
968
|
+
const entries = _ctx.sessionManager.getEntries();
|
|
969
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
970
|
+
const e = entries[i] as {
|
|
971
|
+
type: string;
|
|
972
|
+
customType?: string;
|
|
973
|
+
data?: { name?: unknown };
|
|
974
|
+
};
|
|
975
|
+
if (e.type !== "custom" || e.customType !== "link-name") continue;
|
|
976
|
+
if (typeof e.data?.name === "string") latestSaved = e.data.name;
|
|
977
|
+
break;
|
|
978
|
+
}
|
|
979
|
+
if (latestSaved?.trim().replace(/\s+/g, " ") !== flagName) {
|
|
980
|
+
pi.appendEntry("link-name", { name: flagName });
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
// Critical: only the env path (wrapper combined mode) seeds session name.
|
|
984
|
+
// Public --link-name is link-only.
|
|
985
|
+
if (fromEnv && !pi.getSessionName()) pi.setSessionName(flagName);
|
|
942
986
|
} else {
|
|
943
987
|
const saved = _ctx.sessionManager
|
|
944
988
|
.getEntries()
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-link",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14-beta.0",
|
|
4
4
|
"description": "WebSocket-based inter-terminal communication for Pi. Connect multiple Pi terminals over a local link network.",
|
|
5
5
|
"author": "alvivar",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
8
|
-
"pi-link": "
|
|
8
|
+
"pi-link": "bin/pi-link.mjs"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|