@tian.zuo/pi-rex 0.1.0 → 0.1.1
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 +6 -0
- package/lib/prompt.ts +27 -0
- package/lib/rex-output.ts +27 -0
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @tian.zuo/pi-rex
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Ship `lib/` in the published package. Version 0.1.0 did not load: `index.ts` imports `./lib/rex-output.ts` and `./lib/prompt.ts`, but `files` left `lib/` out of the tarball.
|
|
8
|
+
|
|
3
9
|
## 0.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/lib/prompt.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Model-facing text for pi-rex. Keep every prompt string here, apart from the
|
|
2
|
+
// runtime that injects it.
|
|
3
|
+
|
|
4
|
+
/** System prompt section name. */
|
|
5
|
+
export const REX_SECTION = "rex";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Replaces the Rex session-naming paragraph when the session has more than one
|
|
9
|
+
* tab. A session is the parent of its tabs, so a later tab must not rename it.
|
|
10
|
+
*/
|
|
11
|
+
export const KEEP_SESSION_INSTRUCTION = `The session already has more than one tab. Do not rename the session. Do not run \`rex session rename\`. Keep the current session label.`;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Appended to the Rex session-start output when `rex.renameTab` is true.
|
|
15
|
+
*
|
|
16
|
+
* A session is the parent and a tab is the child: the first tab carries the
|
|
17
|
+
* session label, later tabs get their own label.
|
|
18
|
+
*/
|
|
19
|
+
export const TAB_RENAME_INSTRUCTION = `Name the tab (window) too. Do it in the same step as the session rename. Do not wait for the user to ask.
|
|
20
|
+
|
|
21
|
+
A Rex session is the parent and a tab is the child. The first tab of a session takes the session label. A later tab gets its own label.
|
|
22
|
+
|
|
23
|
+
1. Run \`rex whoami --json\` and read \`.window_id\`.
|
|
24
|
+
2. Run \`rex window ls -s "$REX_SESSION" --json\` and sort the window IDs.
|
|
25
|
+
3. If your window ID is the first ID, use the session label. If not, choose a label for the work in this tab. Use two to four lowercase words joined by hyphens.
|
|
26
|
+
4. Rename with \`rex window rename -s "$REX_SESSION" WINDOW_ID LABEL\`.
|
|
27
|
+
5. Keep a label that already fits the work. If the rename fails, continue the task and do not mention it.`;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Helpers that read and reshape the Rex session-start output.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Remove the paragraph that asks pi to rename the session.
|
|
5
|
+
*
|
|
6
|
+
* Rex marks that paragraph with `rex session rename`, so the match does not
|
|
7
|
+
* depend on the rest of the wording.
|
|
8
|
+
*/
|
|
9
|
+
export function stripSessionNaming(output: string): string {
|
|
10
|
+
return output
|
|
11
|
+
.split(/\n{2,}/)
|
|
12
|
+
.filter((paragraph) => !paragraph.includes("rex session rename"))
|
|
13
|
+
.join("\n\n")
|
|
14
|
+
.trim();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Read `.windows` from `rex session inspect --json` output. */
|
|
18
|
+
export function countWindows(json: string): number | undefined {
|
|
19
|
+
try {
|
|
20
|
+
const parsed: unknown = JSON.parse(json);
|
|
21
|
+
if (typeof parsed !== "object" || parsed === null) return undefined;
|
|
22
|
+
const windows = (parsed as { windows?: unknown }).windows;
|
|
23
|
+
return Array.isArray(windows) ? windows.length : undefined;
|
|
24
|
+
} catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tian.zuo/pi-rex",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Tells the pi coding agent that it runs in a Rex terminal, like the Rex hook for Claude Code and Codex.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"index.ts",
|
|
26
|
+
"lib",
|
|
26
27
|
"CHANGELOG.md"
|
|
27
28
|
],
|
|
28
29
|
"pi": {
|