@zetaloop/chappie 0.2.0 → 0.3.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/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # Chappie
2
2
 
3
- Use ChatGPT to edit files, run commands, and work with [Pi](https://github.com/earendil-works/pi) extensions. Supports multiple Pi sessions, images, and two-way file transfers.
3
+ Use ChatGPT to work through [Pi](https://github.com/earendil-works/pi): edit local files, run commands, call Pi extensions, exchange files and images, and move between sessions on one or more devices.
4
4
 
5
5
  ## Setup
6
6
 
7
- Install through Pi:
7
+ Install the Pi package:
8
8
 
9
9
  ```sh
10
10
  pi install npm:@zetaloop/chappie
11
11
  ```
12
12
 
13
- Add Chappie to your [otunnel](https://github.com/zetaloop/otunnel) configuration:
13
+ Run Chappie as the MCP server managed by [otunnel](https://github.com/zetaloop/otunnel):
14
14
 
15
15
  ```yaml
16
16
  mcp:
@@ -19,16 +19,36 @@ mcp:
19
19
  command: pi --chappie
20
20
  ```
21
21
 
22
- Start otunnel with this configuration and add its tunnel as a developer-mode app in ChatGPT. Run Pi in your project:
22
+ Add the tunnel as a developer-mode app in ChatGPT, then start Pi in a project:
23
23
 
24
24
  ```sh
25
25
  pi --provider chappie --model chatgpt
26
26
  ```
27
27
 
28
- Open Pi with the Chappie provider, then ask ChatGPT to call `init`. Chappie pairs the chat with an online Pi session; the first remote operation starts its turn.
28
+ Call `init` from ChatGPT to connect the conversation to Pi. A conversation can resume an existing task with its Pi session ID, while `sessions` can find connected sessions by device, directory, or name.
29
29
 
30
30
  ## Usage
31
31
 
32
- Ask ChatGPT to work on the task using Chappie's tools. `chat` sends replies to Pi, and new Pi messages accompany subsequent tool results. Interactive tools display their prompts in Pi.
32
+ Chappie exposes common coding tools directly and every active Pi tool through `tools` and `call`. `chat` sends an assistant message to Pi, Pi input accompanies later tool results, and `transfer` moves files in either direction. `ask` can present a persistent question in ChatGPT when webpage questions are enabled.
33
33
 
34
- See the [tool guide](docs/tools.md) for session selection, batch calls, messages, and file and image transfers.
34
+ See the [tool guide](docs/tools.md) for session selection, Pi tools, webpage questions, and file transfer.
35
+
36
+ ## Configuration
37
+
38
+ `chappie.json` in Pi's agent directory configures Chappie.
39
+
40
+ A broker can accept Pi sessions from other devices on the local network:
41
+
42
+ ```json
43
+ { "listen": true }
44
+ ```
45
+
46
+ Remote Pi sessions connect through the broker device's mDNS name:
47
+
48
+ ```json
49
+ { "connect": "<broker>.local" }
50
+ ```
51
+
52
+ The default port is `24274`. Set `listen` to a port number or append `:port` to `connect` to use another one. Only the broker device runs otunnel; local and remote sessions appear in the same session list.
53
+
54
+ Set `ask` to `false` to disable webpage questions. Set `latestWorkflow` to `true` to let a newer otunnel workflow supersede older requests from the same ChatGPT conversation.
package/docs/tools.md CHANGED
@@ -2,58 +2,40 @@
2
2
 
3
3
  | Tool | Purpose |
4
4
  |---|---|
5
- | `init` | Connect to a Pi session and read its environment, tool catalog, skills, global `AGENTS.md`, and pending input. |
6
- | `sessions` | List connected Pi sessions and the chat's default session. |
7
- | `tools` | Read complete definitions for selected active tools. |
5
+ | `init` | Select this ChatGPT conversation's default Pi session and read its environment. |
6
+ | `sessions` | List connected Pi sessions and the current default. |
7
+ | `tools` | Read full definitions of active Pi tools for `call`. |
8
8
  | `chat` | Send an assistant message to Pi. |
9
- | `call` | Run one or more tools as a Pi batch. |
9
+ | `ask` | Create a persistent question in ChatGPT. |
10
+ | `ask_assert` | Confirm that an `ask` widget loaded. |
11
+ | `call` | Run one or more Pi tools as one native batch. |
10
12
  | `read` | Read local text or images. |
11
- | `bash` | Execute a shell command. |
13
+ | `bash` | Run a shell command. |
12
14
  | `edit` | Apply text replacements. |
13
15
  | `write` | Write text to a file. |
14
- | `transfer` | Copy files between ChatGPT and Pi, or export a Pi image as a file. |
15
-
16
- ## Model environment
17
-
18
- The active model is the current ChatGPT conversation. A Pi tool that starts another `chappie/chatgpt` agent cannot create a new browser conversation, so that child waits without a model response. Subagents configured with another provider use that provider normally.
19
-
20
- Use ChatGPT's web search, connectors, and cloud tools for remote research and cloud-side work. Chappie tools operate on local files, processes, Pi extensions, and Pi user interfaces. Pi project-memory tools access their local stores; Pi context-reduction tools do not alter the current ChatGPT conversation.
21
-
22
- Use `chat` for progress or results that should appear in Pi. When a Pi user decision is needed, load the installed interactive tool definition with `tools` and invoke it through `call`.
16
+ | `transfer` | Move files between ChatGPT and Pi or export a Pi image. |
23
17
 
24
18
  ## Sessions
25
19
 
26
- Call `init` with `{}` to reuse the chat's session or pair with the first online, unbound Pi session. A newly opened Pi session can be selected before its first user message; the first remote operation starts its Chappie provider turn.
27
-
28
- `sessions` lists session IDs, working directories, names, and status. `ready` means the provider is accepting output, `executing` means Pi is handling an operation, and `idle` means the next operation will start a turn.
29
-
30
- Use an ID from that list to select a default with `init`:
31
-
32
- ```json
33
- { "sessionId": "<session-id>" }
34
- ```
20
+ Call `init` at the start of local work. Without `sessionId`, it reuses the conversation's saved default or selects an online Pi session with no saved ChatGPT binding. Pass a Pi session ID to resume a specific task, including from another ChatGPT conversation or branch.
35
21
 
36
- The optional `sessionId` on other tools selects a session for that operation. For example, `read` can inspect another project:
22
+ `sessions` lists connected sessions with their ID, device, working directory, name, execution status, and binding count. A conversation can address another session for one operation by supplying that tool's optional `sessionId`; only `init({ sessionId })` changes the saved default.
37
23
 
38
- ```json
39
- { "path": "package.json", "sessionId": "<session-id>" }
40
- ```
24
+ Several ChatGPT conversations can use the same Pi session. One conversation can also operate on several Pi sessions explicitly. Requests already assigned to a session continue there even if the conversation later changes its default.
41
25
 
42
- `sessions({ sessionId })` filters the online list and retrieves available input when that session is connected. The call returns immediately when the selected or bound session is offline; the saved binding is still shown, and deferred results remain available.
26
+ Remote Pi sessions appear in the same list when they connect to a broker exposed through `listen` and `connect`. Their tools, global `AGENTS.md`, files, images, and Pi interfaces come from the remote device.
43
27
 
44
- Several chats can select the same Pi session, and one chat can address several sessions. Defaults are saved in `chappie.state.json` under Pi's agent directory. An existing binding waits for its Pi session to reconnect; `init` with another ID selects a different target.
28
+ ## Pi tools
45
29
 
46
- ## Tool calls
30
+ `read`, `bash`, `edit`, `write`, and `transfer` are available directly. `init` includes a short catalog of the active Pi tools; use `tools` for their complete definitions and `call` to invoke extension tools.
47
31
 
48
- `read`, `bash`, `edit`, and `write` accept Pi's tool parameters plus `sessionId`. Their descriptions provide the current schemas. `init` lists every active tool by name with a short description. Load complete definitions for installed extension tools before calling them:
32
+ For example:
49
33
 
50
34
  ```json
51
35
  { "names": ["ask_user", "ctx_search"] }
52
36
  ```
53
37
 
54
- Omit `names` to return every active definition. Definitions already present in the current ChatGPT context can be reused without another query.
55
-
56
- A single extension tool uses a one-item `calls` array. To request a batch:
38
+ A `call` array is one Pi tool batch:
57
39
 
58
40
  ```json
59
41
  {
@@ -64,46 +46,53 @@ A single extension tool uses a one-item `calls` array. To request a batch:
64
46
  }
65
47
  ```
66
48
 
67
- Each batch returns its results together. Pi determines how its tools run within the batch. Separate calls run in order within one Pi session; different sessions can work independently.
68
-
69
- Extension tools execute through Pi, including their interactive prompts. Results include each tool's name, call ID, error status, and original text or image content.
70
-
71
- ChatGPT file inputs use the direct `transfer` tool. Its top-level `files` parameter lets the host prepare the files before sending them to Pi.
49
+ Pi controls execution inside that batch. Separate requests run in order within one Pi session, while different Pi sessions can work independently. Extension tools retain their native Pi behavior, including interactive interfaces.
72
50
 
73
- ## Messages and interrupted calls
74
-
75
- Call `chat` to display a reply in Pi:
51
+ `chat` creates a normal assistant message in Pi:
76
52
 
77
53
  ```json
78
54
  { "text": "Updated the parser and its callers." }
79
55
  ```
80
56
 
81
- Each call completes one assistant message. Later operations start another turn when Pi is idle. The result returns the target session and any new Pi input without repeating the message text.
82
-
83
- User messages consumed by Pi accompany later Chappie replies, including images. Steering is delivered when Pi consumes it; follow-up uses Pi's normal follow-up timing.
57
+ Pi user input consumed during the work accompanies later Chappie results, including images. Steering and follow-up follow Pi's own delivery timing.
84
58
 
85
- Explicit cancellation removes a queued request or asks Pi to stop its active batch. Available results from that batch accompany a later reply to the originating chat. `sessions` can retrieve them before another tool call. When ChatGPT stops without sending cancellation, local execution continues.
59
+ If a request is explicitly cancelled after local work has produced results, those results can accompany a later response to the originating ChatGPT conversation. Long-running local work is better run through the environment's persistent process facilities instead of occupying one tool request.
86
60
 
87
- Host request deadlines include time spent in the queue. Use local facilities such as tmux for work intended to outlive one call.
61
+ The active model remains the current ChatGPT conversation. Starting another `chappie/chatgpt` agent inside Pi does not create another browser conversation; tools that need another model should use a separately configured provider.
88
62
 
89
- ## Files
63
+ ## Webpage questions
90
64
 
91
- `transfer.paths` names files on the Pi machine. Relative paths resolve from the selected session's working directory. Absolute paths and `~/` work too, including Windows paths such as `C:/Tmp/report.zip`.
92
-
93
- ### ChatGPT to Pi
94
-
95
- Supply matching `paths` and `files` arrays:
65
+ When enabled, `ask` creates a question in ChatGPT and returns its ID immediately:
96
66
 
97
67
  ```json
98
68
  {
99
- "paths": ["assets/reference.png"],
100
- "files": ["/mnt/data/reference.png"]
69
+ "header": "Export format",
70
+ "question": "Which export format should the command use?",
71
+ "context": "Both preserve the required data.",
72
+ "options": [
73
+ { "title": "JSON", "description": "Convenient for programs.", "recommended": true },
74
+ { "title": "CSV", "description": "Convenient for spreadsheets." }
75
+ ]
101
76
  }
102
77
  ```
103
78
 
104
- `files` contains actual cloud paths or attachment references available to ChatGPT. The host converts them into file objects with download URLs before Chappie receives the call.
79
+ Call `ask_assert` with the returned ID to confirm that the widget loaded:
105
80
 
106
- Multiple files are matched by array position:
81
+ ```json
82
+ { "questionId": "<question-id>" }
83
+ ```
84
+
85
+ Answers, revisions, and skips arrive later as `webAnswer` in normal Chappie results. `options` can be omitted for a text answer, and `allowMultiple: true` allows several choices. `sessionId` associates the question with a Pi session without changing the conversation's default.
86
+
87
+ Questions remain available after the assistant response and across broker restarts. Pi's own interactive tools remain ordinary Pi tools and can be invoked through `call`.
88
+
89
+ ## Files
90
+
91
+ `transfer.paths` always names paths or image references on the Pi side. Relative paths resolve from the selected Pi session's working directory; absolute paths and `~/` are accepted.
92
+
93
+ ### ChatGPT to Pi
94
+
95
+ Pair Pi destinations with ChatGPT files:
107
96
 
108
97
  ```json
109
98
  {
@@ -112,7 +101,9 @@ Multiple files are matched by array position:
112
101
  }
113
102
  ```
114
103
 
115
- Chappie creates parent directories and streams each file into its destination. Existing targets produce an error. To replace a file:
104
+ The ChatGPT host turns the cloud paths or attachment references into downloadable file objects before the call reaches Chappie. Chappie creates parent directories and writes each file directly to its destination.
105
+
106
+ Existing targets produce an error by default. Use `overwrite: true` when replacement is intended:
116
107
 
117
108
  ```json
118
109
  {
@@ -122,26 +113,22 @@ Chappie creates parent directories and streams each file into its destination. E
122
113
  }
123
114
  ```
124
115
 
125
- Overwriting truncates the existing file. A failed or canceled download removes the incomplete target opened by that operation, including an overwritten target. Successful files in a batch remain in place; the result reports each file's byte count or error.
116
+ A failed or cancelled transfer removes the incomplete destination opened by that operation. Successful members of a multi-file transfer remain in place.
126
117
 
127
118
  ### Pi to ChatGPT
128
119
 
129
- Omit `files` to export existing files:
120
+ Omit `files` to export existing Pi files:
130
121
 
131
122
  ```json
132
123
  { "paths": ["build/output.zip", "renders/preview.png"] }
133
124
  ```
134
125
 
135
- The result contains resource links with file names, types, and sizes. ChatGPT retrieves the bytes and handles attachment creation and cloud-container access. This may prompt for confirmation.
126
+ Chappie returns MCP resource links. ChatGPT retrieves the bytes when it materializes those resources, which can require user confirmation. A resource remains associated with the Pi session that exported it, so that Pi process and source file need to remain available until the bytes are read.
136
127
 
137
- Each resource refers to its original Pi session, even after the chat selects another default. Keep that Pi process and the source files available while ChatGPT reads them. Files are read when requested. After starting a new Pi process, export again to obtain a fresh reference.
138
-
139
- For a directory, create an archive using a Pi tool and export that file.
128
+ For a directory, create an archive with a Pi tool and export the resulting file.
140
129
 
141
130
  ### Images
142
131
 
143
- `read` sends images directly to ChatGPT for viewing. Images from Pi tools and user messages also include a `piImage` field containing a `chappie://` reference.
144
-
145
- To analyze one in ChatGPT's cloud container, pass the returned reference in `transfer.paths`. This exports the image bytes held by Pi as a file. Include the image's owning `sessionId` when another session is selected.
132
+ `read` and Pi tool results send images directly to ChatGPT for visual inspection. Chappie also returns a `chappie://` image reference with Pi images. Pass that reference to `transfer.paths` when the same bytes are needed as a file in ChatGPT's cloud environment.
146
133
 
147
- To transfer the original image file, use its local path. Pi may resize or convert images for viewing.
134
+ Use the original local path with `transfer` when the original image file is required; Pi can resize or convert images used only for display.
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@zetaloop/chappie",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Connect ChatGPT to Pi",
5
5
  "devDependencies": {
6
6
  "@earendil-works/pi-ai": "^0.85.1",
7
7
  "@earendil-works/pi-coding-agent": "^0.85.1",
8
+ "@earendil-works/pi-tui": "^0.85.1",
8
9
  "@types/node": "^26.5.1",
9
10
  "typebox": "^1.3.30",
10
11
  "typescript": "^7.0.2"
@@ -34,6 +35,7 @@
34
35
  "peerDependencies": {
35
36
  "@earendil-works/pi-ai": "*",
36
37
  "@earendil-works/pi-coding-agent": "*",
38
+ "@earendil-works/pi-tui": "*",
37
39
  "typebox": "*"
38
40
  },
39
41
  "dependencies": {