opencode-supertask 0.1.36 → 0.1.38

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 CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable user-facing changes are recorded here. This project follows semantic versioning while it is in the `0.x` development series.
4
4
 
5
+ ## [0.1.38] - 2026-07-18
6
+
7
+ ### Fixed
8
+
9
+ - `supertask doctor` now reads large resolved OpenCode configurations through a private temporary file, avoiding truncated JSON when OpenCode exits before a captured stdout pipe is fully drained.
10
+ - Successful runs no longer label truncated or unstructured JSONL fragments as failure reasons in task details and execution logs.
11
+
12
+ [0.1.38]: https://github.com/vbgate/opencode-supertask/compare/v0.1.37...v0.1.38
13
+
14
+ ## [0.1.37] - 2026-07-18
15
+
16
+ ### Fixed
17
+
18
+ - Gateway-managed OpenCode runs now set `PWD` to the task working directory, preventing OpenCode server errors when PM2's saved `PWD` differs from the task's `cwd`.
19
+
20
+ [0.1.37]: https://github.com/vbgate/opencode-supertask/compare/v0.1.36...v0.1.37
21
+
5
22
  ## [0.1.36] - 2026-07-18
6
23
 
7
24
  ### Added
package/dist/cli/index.js CHANGED
@@ -22229,8 +22229,18 @@ __export(update_exports, {
22229
22229
  updateGlobalCli: () => updateGlobalCli
22230
22230
  });
22231
22231
  import { spawnSync as spawnSync3 } from "child_process";
22232
- import { existsSync as existsSync6, readFileSync as readFileSync4, readdirSync, realpathSync } from "fs";
22233
- import { homedir as homedir4 } from "os";
22232
+ import {
22233
+ chmodSync as chmodSync3,
22234
+ closeSync,
22235
+ existsSync as existsSync6,
22236
+ mkdtempSync,
22237
+ openSync,
22238
+ readFileSync as readFileSync4,
22239
+ readdirSync,
22240
+ realpathSync,
22241
+ rmSync as rmSync2
22242
+ } from "fs";
22243
+ import { homedir as homedir4, tmpdir as tmpdir2 } from "os";
22234
22244
  import { dirname as dirname7, join as join5, resolve as resolve4 } from "path";
22235
22245
  function pluginAt(packageDir) {
22236
22246
  const packageJson = join5(packageDir, "package.json");
@@ -22467,11 +22477,6 @@ function resolveConfiguredPluginSpec(value) {
22467
22477
  };
22468
22478
  }
22469
22479
  function getOpenCodePluginDiagnostic() {
22470
- const result = spawnSync3(opencodeBin(), ["debug", "config", "--pure"], {
22471
- encoding: "utf8",
22472
- env: process.env,
22473
- timeout: 3e4
22474
- });
22475
22480
  const failed = (message) => ({
22476
22481
  ok: false,
22477
22482
  spec: "",
@@ -22481,51 +22486,77 @@ function getOpenCodePluginDiagnostic() {
22481
22486
  packageDir: null,
22482
22487
  error: message
22483
22488
  });
22484
- if (result.error) {
22485
- return failed(`[supertask] \u65E0\u6CD5\u8BFB\u53D6 OpenCode \u6700\u7EC8\u914D\u7F6E: ${result.error.message}`);
22486
- }
22487
- if (result.status !== 0) {
22488
- const detail = `${result.stderr ?? ""}`.trim();
22489
- return failed(`[supertask] \u65E0\u6CD5\u8BFB\u53D6 OpenCode \u6700\u7EC8\u914D\u7F6E: ${detail || `\u9000\u51FA\u7801 ${result.status}`}`);
22490
- }
22491
- let config;
22489
+ let outputDirectory = null;
22490
+ let outputFd = null;
22492
22491
  try {
22493
- config = JSON.parse(`${result.stdout ?? ""}`);
22494
- } catch {
22495
- return failed("[supertask] OpenCode \u6700\u7EC8\u914D\u7F6E\u4E0D\u662F\u6709\u6548 JSON");
22496
- }
22497
- let configured;
22498
- try {
22499
- configured = resolveConfiguredPluginSpec(config);
22500
- } catch (error) {
22501
- return failed(error instanceof Error ? error.message : String(error));
22502
- }
22503
- if (!configured.exact || configured.version === null) {
22504
- return {
22505
- ok: false,
22506
- ...configured,
22507
- cachedVersion: null,
22508
- packageDir: null,
22509
- error: `[supertask] OpenCode \u63D2\u4EF6\u5FC5\u987B\u56FA\u5B9A\u7CBE\u786E\u7248\u672C\uFF0C\u4E0D\u80FD\u4F7F\u7528 ${configured.spec}`
22510
- };
22511
- }
22512
- try {
22513
- const installed = resolveInstalledPluginVersion(configured.version);
22514
- return {
22515
- ok: true,
22516
- ...configured,
22517
- cachedVersion: installed.version,
22518
- packageDir: installed.packageDir,
22519
- error: null
22520
- };
22492
+ outputDirectory = mkdtempSync(join5(tmpdir2(), "opencode-supertask-config-"));
22493
+ chmodSync3(outputDirectory, 448);
22494
+ const outputPath = join5(outputDirectory, "resolved-config.json");
22495
+ outputFd = openSync(outputPath, "w", 384);
22496
+ const result = spawnSync3(opencodeBin(), ["debug", "config", "--pure"], {
22497
+ encoding: "utf8",
22498
+ env: process.env,
22499
+ timeout: 3e4,
22500
+ stdio: ["ignore", outputFd, "pipe"]
22501
+ });
22502
+ closeSync(outputFd);
22503
+ outputFd = null;
22504
+ if (result.error) {
22505
+ return failed(`[supertask] \u65E0\u6CD5\u8BFB\u53D6 OpenCode \u6700\u7EC8\u914D\u7F6E: ${result.error.message}`);
22506
+ }
22507
+ if (result.status !== 0) {
22508
+ const detail = `${result.stderr ?? ""}`.trim();
22509
+ return failed(`[supertask] \u65E0\u6CD5\u8BFB\u53D6 OpenCode \u6700\u7EC8\u914D\u7F6E: ${detail || `\u9000\u51FA\u7801 ${result.status}`}`);
22510
+ }
22511
+ let config;
22512
+ try {
22513
+ config = JSON.parse(readFileSync4(outputPath, "utf8"));
22514
+ } catch {
22515
+ return failed("[supertask] OpenCode \u6700\u7EC8\u914D\u7F6E\u4E0D\u662F\u6709\u6548 JSON");
22516
+ }
22517
+ let configured;
22518
+ try {
22519
+ configured = resolveConfiguredPluginSpec(config);
22520
+ } catch (error) {
22521
+ return failed(error instanceof Error ? error.message : String(error));
22522
+ }
22523
+ if (!configured.exact || configured.version === null) {
22524
+ return {
22525
+ ok: false,
22526
+ ...configured,
22527
+ cachedVersion: null,
22528
+ packageDir: null,
22529
+ error: `[supertask] OpenCode \u63D2\u4EF6\u5FC5\u987B\u56FA\u5B9A\u7CBE\u786E\u7248\u672C\uFF0C\u4E0D\u80FD\u4F7F\u7528 ${configured.spec}`
22530
+ };
22531
+ }
22532
+ try {
22533
+ const installed = resolveInstalledPluginVersion(configured.version);
22534
+ return {
22535
+ ok: true,
22536
+ ...configured,
22537
+ cachedVersion: installed.version,
22538
+ packageDir: installed.packageDir,
22539
+ error: null
22540
+ };
22541
+ } catch (error) {
22542
+ return {
22543
+ ok: false,
22544
+ ...configured,
22545
+ cachedVersion: null,
22546
+ packageDir: null,
22547
+ error: error instanceof Error ? error.message : String(error)
22548
+ };
22549
+ }
22521
22550
  } catch (error) {
22522
- return {
22523
- ok: false,
22524
- ...configured,
22525
- cachedVersion: null,
22526
- packageDir: null,
22527
- error: error instanceof Error ? error.message : String(error)
22528
- };
22551
+ return failed(`[supertask] \u65E0\u6CD5\u8BFB\u53D6 OpenCode \u6700\u7EC8\u914D\u7F6E: ${error instanceof Error ? error.message : String(error)}`);
22552
+ } finally {
22553
+ if (outputFd !== null) {
22554
+ try {
22555
+ closeSync(outputFd);
22556
+ } catch {
22557
+ }
22558
+ }
22559
+ if (outputDirectory !== null) rmSync2(outputDirectory, { recursive: true, force: true });
22529
22560
  }
22530
22561
  }
22531
22562
  function installPluginVersion(version2) {
@@ -22909,6 +22940,7 @@ var init_worker = __esm({
22909
22940
  const args = ["run", "--agent", task.agent, "--format", "json"];
22910
22941
  if (model) args.push("-m", model);
22911
22942
  args.push(task.prompt);
22943
+ const cwd = task.cwd || process.cwd();
22912
22944
  const child = spawn(process.execPath, [
22913
22945
  this.launcherEntry(),
22914
22946
  LAUNCH_IDENTITY_ARGUMENT,
@@ -22916,9 +22948,10 @@ var init_worker = __esm({
22916
22948
  this.opencodeBin,
22917
22949
  ...args
22918
22950
  ], {
22919
- cwd: task.cwd || process.cwd(),
22951
+ cwd,
22920
22952
  env: {
22921
22953
  ...process.env,
22954
+ PWD: cwd,
22922
22955
  [MANAGED_RUN_ENV]: MANAGED_RUN_ENV_VALUE
22923
22956
  },
22924
22957
  stdio: ["pipe", "pipe", "pipe", "ipc"],
@@ -22929,7 +22962,7 @@ var init_worker = __esm({
22929
22962
  runId,
22930
22963
  launchIdentity,
22931
22964
  child,
22932
- commandContext: runCommandContext(this.opencodeBin, args, task.cwd || process.cwd()),
22965
+ commandContext: runCommandContext(this.opencodeBin, args, cwd),
22933
22966
  output: "",
22934
22967
  sessionId: null,
22935
22968
  timeoutTimer: null,
@@ -27738,7 +27771,7 @@ function shellQuote(value) {
27738
27771
  if (/^[A-Za-z0-9_./:@%+=,-]+$/.test(value)) return value;
27739
27772
  return `'${value.replace(/'/g, `'"'"'`)}'`;
27740
27773
  }
27741
- function presentRunLog(log) {
27774
+ function presentRunLog(log, includeErrors = true) {
27742
27775
  let command = null;
27743
27776
  const textParts = [];
27744
27777
  const errors = [];
@@ -27750,7 +27783,7 @@ function presentRunLog(log) {
27750
27783
  try {
27751
27784
  parsed = recordValue(JSON.parse(trimmed));
27752
27785
  } catch {
27753
- errors.push(line);
27786
+ if (includeErrors) errors.push(line);
27754
27787
  continue;
27755
27788
  }
27756
27789
  if (!parsed) continue;
@@ -27774,7 +27807,7 @@ function presentRunLog(log) {
27774
27807
  const tool = typeof part?.tool === "string" ? part.tool : typeof parsed.tool === "string" ? parsed.tool : null;
27775
27808
  if (tool && (eventType === "tool_use" || partType === "tool")) tools.push(tool);
27776
27809
  const error = typeof parsed.error === "string" ? parsed.error : typeof part?.error === "string" ? part.error : null;
27777
- if (error) errors.push(error);
27810
+ if (error && includeErrors) errors.push(error);
27778
27811
  }
27779
27812
  return {
27780
27813
  command,
@@ -27783,8 +27816,8 @@ function presentRunLog(log) {
27783
27816
  tools
27784
27817
  };
27785
27818
  }
27786
- function renderRunLog(runId, taskName, log, locale) {
27787
- const presentation = presentRunLog(log);
27819
+ function renderRunLog(runId, taskName, log, locale, includeErrors) {
27820
+ const presentation = presentRunLog(log, includeErrors);
27788
27821
  const command = presentation.command ? `<div class="run-command"><div class="log-section-head"><strong>${t(locale, "logs.command")}</strong><button type="button" class="btn" onclick="copyRunCommand(${runId})">${icon("copy")}${t(locale, "action.copyCommand")}</button></div><div class="command-cwd">${esc(presentation.command.cwd)}</div><pre id="command-${runId}">${esc(presentation.command.command)}</pre></div>` : "";
27789
27822
  const errors = presentation.errors.length > 0 ? `<div class="run-error"><strong>${t(locale, "logs.error")}</strong><pre>${esc(presentation.errors.join("\n"))}</pre></div>` : "";
27790
27823
  const tools = presentation.tools.length > 0 ? `<div class="run-tools"><strong>${t(locale, "logs.tools")}</strong><div class="actions">${presentation.tools.map((tool) => `<span class="tag">${esc(tool)}</span>`).join("")}</div></div>` : "";
@@ -28232,7 +28265,7 @@ var init_web = __esm({
28232
28265
  const rows = runs.map((run) => {
28233
28266
  const status = safeStatus(run.status);
28234
28267
  const resumable = isValidSessionId(run.sessionId);
28235
- const log = run.log ? renderRunLog(run.id, run.taskName, run.log, locale) : "";
28268
+ const log = run.log ? renderRunLog(run.id, run.taskName, run.log, locale, run.status !== "done") : "";
28236
28269
  return `<tr class="run-summary-row">
28237
28270
  <td class="faint" data-label="${t(locale, "table.run")}">#${run.id}</td>
28238
28271
  <td data-primary data-label="${t(locale, "table.task")}"><div class="task-name">${esc(run.taskName)} <span class="faint">#${run.taskId}</span></div>${run.model ? `<div style="margin-top:4px"><span class="tag">${esc(run.model)}</span></div>` : ""}</td>
@@ -28363,7 +28396,7 @@ var init_web = __esm({
28363
28396
  const runs = await TaskRunService.listByTaskId(id);
28364
28397
  return c.json({
28365
28398
  ...task,
28366
- _resultPresentation: task.resultLog ? presentRunLog(task.resultLog) : null,
28399
+ _resultPresentation: task.resultLog ? presentRunLog(task.resultLog, task.status !== "done") : null,
28367
28400
  _runs: runs
28368
28401
  });
28369
28402
  });