@usepipa/pipa 0.1.0 → 0.2.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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usepipa/pipa",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Run Pipa locally through Slack and OpenCode",
5
5
  "keywords": ["slack", "opencode", "ai-agent", "cli"],
6
6
  "type": "module",
package/src/app.mjs CHANGED
@@ -199,7 +199,7 @@ function slackContext(thread, message) {
199
199
 
200
200
  async function postInChunks(thread, text) {
201
201
  for (let index = 0; index < text.length; index += 3500) {
202
- await thread.post(text.slice(index, index + 3500));
202
+ await thread.post({ markdown: text.slice(index, index + 3500) });
203
203
  }
204
204
  }
205
205
 
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,