@usepipa/pipa 0.1.0 → 0.2.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 +7 -0
- package/package.json +1 -1
- package/src/opencode.mjs +4 -2
package/README.md
CHANGED
|
@@ -39,6 +39,13 @@ pipa start
|
|
|
39
39
|
|
|
40
40
|
Keep `pipa start` running, invite Pipa to a trusted public or private Slack channel, and mention it there. Pipa replies in a thread, and follow-up messages in that thread do not need another mention.
|
|
41
41
|
|
|
42
|
+
To use an existing OpenCode server instead of starting standalone OpenCode runs, set its URL before starting Pipa:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
export PIPA_OPENCODE_ATTACH_URL=http://localhost:5555
|
|
46
|
+
pipa start
|
|
47
|
+
```
|
|
48
|
+
|
|
42
49
|
## Commands
|
|
43
50
|
|
|
44
51
|
```text
|
package/package.json
CHANGED
package/src/opencode.mjs
CHANGED
|
@@ -11,8 +11,9 @@ export function cleanChildEnvironment(environment = process.env) {
|
|
|
11
11
|
return Object.fromEntries(Object.entries(environment).filter(([key]) => !SECRET_ENV_KEYS.has(key.toUpperCase())));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function buildRunArguments({ prompt, sessionId, workingDirectory }) {
|
|
14
|
+
export function buildRunArguments({ prompt, sessionId, workingDirectory, attachUrl }) {
|
|
15
15
|
const args = ["run", "--format", "json", "--dir", workingDirectory];
|
|
16
|
+
if (attachUrl) args.push("--attach", attachUrl);
|
|
16
17
|
if (sessionId) args.push("--session", sessionId);
|
|
17
18
|
args.push("--", prompt);
|
|
18
19
|
return args;
|
|
@@ -22,12 +23,13 @@ export function createOpenCodeExecutor(options = {}) {
|
|
|
22
23
|
const spawn = options.spawn ?? crossSpawn;
|
|
23
24
|
const platform = options.platform ?? process.platform;
|
|
24
25
|
const environment = options.environment ?? process.env;
|
|
26
|
+
const attachUrl = options.attachUrl ?? environment.PIPA_OPENCODE_ATTACH_URL?.trim();
|
|
25
27
|
const timeoutMs = options.timeoutMs ?? 2.5 * 60 * 60 * 1000;
|
|
26
28
|
const children = new Set();
|
|
27
29
|
|
|
28
30
|
async function runTurn({ prompt, sessionId, workingDirectory, contextEnvironment = {} }) {
|
|
29
31
|
if (!prompt?.trim()) throw new Error("A prompt is required.");
|
|
30
|
-
const child = spawn("opencode", buildRunArguments({ prompt, sessionId, workingDirectory }), {
|
|
32
|
+
const child = spawn("opencode", buildRunArguments({ prompt, sessionId, workingDirectory, attachUrl }), {
|
|
31
33
|
cwd: workingDirectory,
|
|
32
34
|
env: { ...cleanChildEnvironment(environment), ...contextEnvironment },
|
|
33
35
|
shell: false,
|