@losoft/taube 0.1.5 → 0.1.6

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
@@ -14,13 +14,17 @@ You can also use the Taube command directly from a shell or script.
14
14
 
15
15
  ## Install Taube
16
16
 
17
- You need Node.js 22.13 or later and npm to install the Taube command. Install the CLI for the host you want to use. Sign in to each target agent you plan to dispatch.
17
+ You need Node.js 22.13 or later and npm. Install the CLI for the host where you start tasks. Sign in to each target agent you plan to use.
18
+
19
+ Install Taube globally from [npm](https://www.npmjs.com/package/@losoft/taube).
18
20
 
19
21
  ```sh
20
22
  npm install -g @losoft/taube
21
23
  taube surfaces
22
24
  ```
23
25
 
26
+ The `taube surfaces` command lists supported targets and their effort options in JSON. The `launcher.onPath` field shows whether Taube found the ACP launcher for that target on `PATH`. Taube reports the sign-in status as `unverified`. On the first dispatch to a target, `acpx` can install its adapter through npm.
27
+
24
28
  ### Install from GitHub
25
29
 
26
30
  To install from GitHub, you also need Git and Bun 1.4.2 or later. Keep `bun` on your `PATH` during installation. If you use npm 12, add `--allow-git=root` to the install command.
@@ -33,8 +37,6 @@ taube surfaces
33
37
 
34
38
  Add the `export PATH` line to your shell startup file to use Taube in future sessions.
35
39
 
36
- `taube surfaces` lists the supported targets and names their effort options in JSON. It checks your `PATH` for each target's ACP launcher. Sign-in status remains unverified. On first use, `acpx` can install the target's adapter through npm.
37
-
38
40
  ### Install your host plugin
39
41
 
40
42
  Choose the host you use to start the task. Start the host from a shell with `taube` on its `PATH`.
@@ -125,7 +127,9 @@ To run installation checks for Codex, Claude Code, and Grok Build, put `codex`,
125
127
  TAUBE_TEST_NATIVE_PLUGINS=1 bun test test/plugins.test.ts
126
128
  ```
127
129
 
128
- Contributions go through pull requests. CI checks the build, types, formatting, tests, and synchronized patch versions. [Contributor instructions](AGENTS.md)
130
+ Contributions go through pull requests. CI checks the build, types, formatting, tests, and synchronized patch versions.
131
+
132
+ When a merge changes the npm package, CI publishes a new npm version. For this check, CI ignores the root README, version numbers, and development metadata. [Contributor instructions](AGENTS.md)
129
133
 
130
134
  ## License
131
135
 
package/dist/cli.js CHANGED
@@ -1,15 +1,59 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { parseArgs } from "node:util";
5
+
6
+ // src/acpx.ts
4
7
  import { spawn } from "node:child_process";
5
8
  import { once } from "node:events";
6
- import { accessSync, constants as fsConstants, statSync } from "node:fs";
7
9
  import { createRequire } from "node:module";
8
10
  import { constants } from "node:os";
9
- import { delimiter, resolve } from "node:path";
10
- import { createInterface } from "node:readline";
11
+ import { resolve as resolve2 } from "node:path";
11
12
  import { text } from "node:stream/consumers";
12
- import { parseArgs } from "node:util";
13
+
14
+ // src/prompt-events.ts
15
+ import { createInterface } from "node:readline";
16
+ function parseEvent(line) {
17
+ try {
18
+ const event = JSON.parse(line);
19
+ if (event && typeof event === "object")
20
+ return event;
21
+ } catch {}
22
+ }
23
+ function assistantText(event) {
24
+ const update = event.params?.update;
25
+ if (event.method === "session/update" && update?.sessionUpdate === "agent_message_chunk" && update.content?.type === "text" && typeof update.content.text === "string") {
26
+ return update.content.text;
27
+ }
28
+ }
29
+ async function readPromptEvents(input, writeText) {
30
+ const result = { malformed: false };
31
+ let promptId;
32
+ const lines = createInterface({ input, crlfDelay: Infinity });
33
+ for await (const line of lines) {
34
+ const event = parseEvent(line);
35
+ if (!event) {
36
+ result.malformed = true;
37
+ continue;
38
+ }
39
+ if (event.method === "session/prompt")
40
+ promptId = event.id;
41
+ const chunk = assistantText(event);
42
+ if (chunk !== undefined)
43
+ await writeText(chunk);
44
+ if (promptId !== undefined && event.id === promptId && typeof event.result?.stopReason === "string") {
45
+ result.stopReason = event.result.stopReason;
46
+ }
47
+ if (typeof event.error?.message === "string") {
48
+ result.lastError = event.error.message;
49
+ }
50
+ }
51
+ return result;
52
+ }
53
+
54
+ // src/targets.ts
55
+ import { accessSync, constants as fsConstants, statSync } from "node:fs";
56
+ import { delimiter, resolve } from "node:path";
13
57
  var targets = [
14
58
  {
15
59
  id: "codex",
@@ -36,17 +80,6 @@ var targets = [
36
80
  effortOption: null
37
81
  }
38
82
  ];
39
- var targetIds = targets.map(({ id }) => id);
40
- var help = `Usage:
41
- taube surfaces
42
- taube dispatch <${targetIds.join("|")}> [--model ID] [--effort LEVEL] [--cwd DIR]
43
-
44
- surfaces lists supported targets and checks each built-in ACP launcher on PATH.
45
- dispatch reads one instruction from stdin, starts a fresh session, and streams
46
- assistant text to stdout. Diagnostics go to stderr. A partial turn exits nonzero.
47
- Omit model and effort to use the target defaults.
48
- For Cursor, select an advertised model variant with --model. Cursor through
49
- acpx does not expose a separate --effort setting.`;
50
83
  function executableOnPath(command) {
51
84
  const extensions = process.platform === "win32" ? (process.env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";") : [""];
52
85
  for (const directory of (process.env.PATH ?? "").split(delimiter)) {
@@ -74,11 +107,53 @@ function surfaces() {
74
107
  }))
75
108
  };
76
109
  }
77
- async function runAcpx(args, cwd, codex) {
110
+
111
+ // src/acpx.ts
112
+ function acpxArguments(target, cwd, { model, effort }) {
113
+ const acpxArgs = [
114
+ "--cwd",
115
+ cwd,
116
+ "--format",
117
+ "json",
118
+ "--non-interactive-permissions",
119
+ "fail",
120
+ "--prompt-retries",
121
+ "0"
122
+ ];
123
+ if (model)
124
+ acpxArgs.push("--model", model);
125
+ acpxArgs.push(target.profile, "exec", "--file", "-");
126
+ if (effort) {
127
+ if (!target.effortOption)
128
+ throw new Error("Cursor through acpx does not support a separate --effort setting. Use --model with an advertised Cursor model variant.");
129
+ acpxArgs.push("--config-option", `${target.effortOption}=${effort}`);
130
+ }
131
+ return acpxArgs;
132
+ }
133
+ function exitCode(status, signal, { malformed, stopReason, lastError }) {
134
+ if (signal) {
135
+ console.error(`taube: interrupted (${signal})`);
136
+ return 128 + constants.signals[signal];
137
+ }
138
+ if (status !== 0) {
139
+ console.error(`taube: ${lastError ?? `acpx exited with status ${status}`}`);
140
+ return status ?? 1;
141
+ }
142
+ if (malformed || !stopReason)
143
+ throw new Error("acpx returned an incomplete or invalid event stream");
144
+ if (stopReason !== "end_turn") {
145
+ console.error(`taube: target stopped with ${stopReason}`);
146
+ return stopReason === "cancelled" ? 130 : 1;
147
+ }
148
+ return 0;
149
+ }
150
+ async function runAcpx(target, options) {
151
+ const cwd = resolve2(options.cwd ?? ".");
152
+ const args = acpxArguments(target, cwd, options);
78
153
  const instruction = await text(process.stdin);
79
154
  if (!instruction.trim())
80
155
  throw new Error("Supply a non-empty instruction on stdin.");
81
- const codexPath = codex && process.env.CODEX_PATH === undefined ? executableOnPath("codex") : null;
156
+ const codexPath = target.id === "codex" && process.env.CODEX_PATH === undefined ? executableOnPath("codex") : null;
82
157
  const acpx = createRequire(import.meta.url).resolve("acpx");
83
158
  const child = spawn(process.execPath, [acpx, ...args], {
84
159
  cwd,
@@ -98,75 +173,48 @@ async function runAcpx(args, cwd, codex) {
98
173
  child.kill(signal);
99
174
  };
100
175
  const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
101
- const handlers = signals.map((signal) => () => forwardSignal(signal));
102
- for (const [index, signal] of signals.entries())
103
- process.on(signal, handlers[index]);
104
- let promptId;
105
- let stopReason;
106
- let malformed = false;
107
- let lastError;
176
+ for (const signal of signals)
177
+ process.on(signal, forwardSignal);
108
178
  let outputError;
109
179
  const onOutputError = (error) => {
110
180
  outputError = error;
111
181
  child.kill("SIGTERM");
112
182
  };
113
183
  process.stdout.on("error", onOutputError);
114
- try {
115
- const lines = createInterface({
116
- input: child.stdout,
117
- crlfDelay: Infinity
118
- });
119
- for await (const line of lines) {
120
- let event;
121
- try {
122
- event = JSON.parse(line);
123
- if (!event || typeof event !== "object")
124
- throw new Error;
125
- } catch {
126
- malformed = true;
127
- continue;
128
- }
129
- if (event.method === "session/prompt")
130
- promptId = event.id;
131
- const update = event.params?.update;
132
- if (!outputError && event.method === "session/update" && update?.sessionUpdate === "agent_message_chunk" && update.content?.type === "text" && typeof update.content.text === "string") {
133
- if (!process.stdout.write(update.content.text))
134
- await once(process.stdout, "drain");
135
- }
136
- if (promptId !== undefined && event.id === promptId && typeof event.result?.stopReason === "string")
137
- stopReason = event.result.stopReason;
138
- if (typeof event.error?.message === "string")
139
- lastError = event.error.message;
184
+ const writeText = async (chunk) => {
185
+ if (!outputError && !process.stdout.write(chunk)) {
186
+ await once(process.stdout, "drain");
140
187
  }
188
+ };
189
+ try {
190
+ const result = await readPromptEvents(child.stdout, writeText);
141
191
  const [status, exitSignal] = await exited;
142
192
  if (outputError)
143
193
  throw outputError;
144
- const signal = interrupted ?? exitSignal;
145
- if (signal) {
146
- console.error(`taube: interrupted (${signal})`);
147
- return 128 + constants.signals[signal];
148
- }
149
- if (status !== 0) {
150
- console.error(`taube: ${lastError ?? `acpx exited with status ${status}`}`);
151
- return status ?? 1;
152
- }
153
- if (malformed || !stopReason)
154
- throw new Error("acpx returned an incomplete or invalid event stream");
155
- if (stopReason !== "end_turn") {
156
- console.error(`taube: target stopped with ${stopReason}`);
157
- return stopReason === "cancelled" ? 130 : 1;
158
- }
159
- return 0;
194
+ return exitCode(status, interrupted ?? exitSignal, result);
160
195
  } finally {
161
196
  if (child.exitCode === null && child.signalCode === null) {
162
197
  child.kill("SIGTERM");
163
198
  await exited.catch(() => {});
164
199
  }
165
200
  process.stdout.off("error", onOutputError);
166
- for (const [index, signal] of signals.entries())
167
- process.off(signal, handlers[index]);
201
+ for (const signal of signals)
202
+ process.off(signal, forwardSignal);
168
203
  }
169
204
  }
205
+
206
+ // src/cli.ts
207
+ var targetIds = targets.map(({ id }) => id);
208
+ var help = `Usage:
209
+ taube surfaces
210
+ taube dispatch <${targetIds.join("|")}> [--model ID] [--effort LEVEL] [--cwd DIR]
211
+
212
+ surfaces lists supported targets and checks each built-in ACP launcher on PATH.
213
+ dispatch reads one instruction from stdin, starts a fresh session, and streams
214
+ assistant text to stdout. Diagnostics go to stderr. A partial turn exits nonzero.
215
+ Omit model and effort to use the target defaults.
216
+ For Cursor, select an advertised model variant with --model. Cursor through
217
+ acpx does not expose a separate --effort setting.`;
170
218
  async function main([command, targetId, ...args]) {
171
219
  if (!command || command === "--help" || command === "-h" || command === "dispatch" && (targetId === "--help" || targetId === "-h")) {
172
220
  console.log(help);
@@ -198,26 +246,7 @@ async function main([command, targetId, ...args]) {
198
246
  if (typeof value === "string" && !value.trim())
199
247
  throw new Error(`--${name} needs a non-empty value`);
200
248
  }
201
- const cwd = resolve(values.cwd ?? ".");
202
- const acpxArgs = [
203
- "--cwd",
204
- cwd,
205
- "--format",
206
- "json",
207
- "--non-interactive-permissions",
208
- "fail",
209
- "--prompt-retries",
210
- "0"
211
- ];
212
- if (values.model)
213
- acpxArgs.push("--model", values.model);
214
- acpxArgs.push(target.profile, "exec", "--file", "-");
215
- if (values.effort) {
216
- if (!target.effortOption)
217
- throw new Error("Cursor through acpx does not support a separate --effort setting. Use --model with an advertised Cursor model variant.");
218
- acpxArgs.push("--config-option", `${target.effortOption}=${values.effort}`);
219
- }
220
- return runAcpx(acpxArgs, cwd, target.id === "codex");
249
+ return runAcpx(target, values);
221
250
  }
222
251
  try {
223
252
  process.exitCode = await main(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@losoft/taube",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Delegate a coding task to Codex, Claude Code, Grok Build, or Cursor through acpx.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taube",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Dispatch coding agents from the terminal with Taube.",
5
5
  "author": {
6
6
  "name": "Taube contributors"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taube",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Dispatch coding agents from the terminal with Taube.",
5
5
  "license": "MIT",
6
6
  "skills": "./skills/",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taube",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Dispatch coding agents from the terminal with Taube.",
5
5
  "author": {
6
6
  "name": "Taube contributors"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taube",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Dispatch coding agents from the terminal with Taube.",
5
5
  "license": "MIT"
6
6
  }