teapot-coding-agent 0.37.139 → 0.37.141

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.
@@ -5,7 +5,7 @@ import { storeImage, resolveImages } from "../log/image-store.js";
5
5
  import { chat, chatStream } from "./llm.js";
6
6
  import { auditPrompt, parseAuditVerdict } from "./goal-audit.js";
7
7
  import { createCatalog } from "./tool-catalog.js";
8
- import { resetToolCatalog, executeTool, toolSpecs, currentSkills, safeJoin, isContextOverflow, isRequestNodeLimit, hasRunningBgShells, hasRunningBgShellsFor, killBgShells, runningBgShellCount } from "./tools.js";
8
+ import { resetToolCatalog, executeTool, toolSpecs, currentSkills, safeJoin, isContextOverflow, isRequestNodeLimit, hasRunningBgShellsFor, killBgShells, runningBgShellCount } from "./tools.js";
9
9
  import { effortChoosable } from "./llm.js";
10
10
  import { turnAnchor } from "./timing.js";
11
11
  import { claimsContextLimit, claimsOwnLimit, usageLine } from "./context-claim.js";
@@ -1122,7 +1122,15 @@ export class Agent {
1122
1122
  parts.push(`NOT FOUND in todo.md: ${unmatched.map((s) => `"${s}"`).join(", ")} — check get_todo and retry with the exact wording, or use action:"add" to create it`);
1123
1123
  return parts.join(". ");
1124
1124
  }
1125
- async setGoalStatus(status, by = "operator") {
1125
+ /**
1126
+ * `by` is REQUIRED: the default was "operator", and the agent's own `finish(goalComplete=true)` was logged with it.
1127
+ *
1128
+ * The timeline then rendered "you marked this goal done — no audit runs for a manual completion" for a completion the
1129
+ * AGENT had claimed and that was supposed to be audited ("finish(goalComplete=true) なのに … が発行される"). A
1130
+ * default that guesses the actor is exactly the kind of thing that is right until somebody forgets an argument, so the
1131
+ * compiler asks now.
1132
+ */
1133
+ async setGoalStatus(status, by) {
1126
1134
  this.goal = { ...this.goal, status, updatedAt: new Date().toISOString() };
1127
1135
  await this.writeGoalFile();
1128
1136
  await this.log.append("goal", this.currentSession, this.currentBranch, {
@@ -1462,7 +1470,17 @@ export class Agent {
1462
1470
  }
1463
1471
  if (this.pendingPrompts.length)
1464
1472
  continue;
1465
- if (hasRunningBgShells(this.toolCtx.cwd)) {
1473
+ /**
1474
+ * Suppress the continue only for a job THIS agent started.
1475
+ *
1476
+ * The check used to be workspace-wide (`hasRunningBgShells(cwd)`), and the resume is owner-scoped: the exit
1477
+ * notification goes to `ctx.onBackgroundExit`, i.e. to the agent that launched the job. Sub-agents share their
1478
+ * parent's workspace, so a child's `sleep 300` suppressed the PARENT's auto-continue while the parent's own
1479
+ * path back (`auto-continue-suppressed` → resume on exit) could never fire — the parent simply stopped.
1480
+ * `isLive()` has always asked the owner-scoped question (`hasRunningBgShellsFor`); these two sites now agree
1481
+ * with it.
1482
+ */
1483
+ if (hasRunningBgShellsFor(this.toolCtx.cwd, this.opts.id)) {
1466
1484
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
1467
1485
  event: "auto-continue-suppressed",
1468
1486
  reason: "background job still running — the agent resumes when it exits",
@@ -1744,7 +1762,8 @@ export class Agent {
1744
1762
  * when it exits (`auto-continue-suppressed`), so the summary needs no blocker vocabulary. Asking here
1745
1763
  * broke that path (measured: "auto-continue is suppressed while a background bash runs").
1746
1764
  */
1747
- !hasRunningBgShells(this.toolCtx.cwd) &&
1765
+ // owner-scoped for the same reason as the suppression above: a sibling's job is not this agent's excuse
1766
+ !hasRunningBgShellsFor(this.toolCtx.cwd, this.opts.id) &&
1748
1767
  !namesBlocker(String(fin.summary ?? ""))) {
1749
1768
  this.blockerAsks += 1;
1750
1769
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
@@ -2693,7 +2712,7 @@ export class Agent {
2693
2712
  }
2694
2713
  }
2695
2714
  else {
2696
- await this.setGoalStatus("done");
2715
+ await this.setGoalStatus("done", "agent");
2697
2716
  }
2698
2717
  }
2699
2718
  await this.appendFinalMessage(args);
@@ -45,6 +45,11 @@ export function editorConfigFor(targetPath) {
45
45
  out = { ...out, finalNewline: true };
46
46
  else if (fn === "false")
47
47
  out = { ...out, finalNewline: false };
48
+ const tt = section.props.get("trim_trailing_whitespace");
49
+ if (tt === "true")
50
+ out = { ...out, trimTrailingWhitespace: true };
51
+ else if (tt === "false")
52
+ out = { ...out, trimTrailingWhitespace: false };
48
53
  }
49
54
  }
50
55
  return out;
@@ -90,6 +90,21 @@ export function detectEol(text) {
90
90
  export function splitEolLines(text) {
91
91
  return text.split(/\r\n|\r|\n/);
92
92
  }
93
+ /**
94
+ * Strip trailing whitespace from every line, as `.editorconfig`'s `trim_trailing_whitespace = true` asks.
95
+ *
96
+ * A file written by the agent should look like a file written by a person in that repository; leaving trailing spaces
97
+ * behind is what makes `git diff --check` complain on somebody else's commit. Line endings are untouched here — that is
98
+ * `applyEol`'s job, and the two compose in ONE place (`applyEditorConfig`) so a caller cannot apply one and forget the
99
+ * other.
100
+ */
101
+ export function trimTrailingWhitespace(content) {
102
+ return content.replace(/[ \t]+(?=\r?\n|$)/g, "");
103
+ }
104
+ export function applyEditorConfig(content, ec) {
105
+ const trimmed = ec.trimTrailingWhitespace === true ? trimTrailingWhitespace(content) : content;
106
+ return applyEol(trimmed, ec.eol);
107
+ }
93
108
  export function applyEol(content, eol) {
94
109
  if (!eol || eol === "\n")
95
110
  return content;
@@ -1262,7 +1277,7 @@ export const TOOLS = [
1262
1277
  if (detected !== null)
1263
1278
  return finishWrite(p, applyEol(args.content, detected), detected, args.content);
1264
1279
  const ec = editorConfigFor(p);
1265
- const out = applyEol(args.content, ec.eol);
1280
+ const out = applyEditorConfig(args.content, ec);
1266
1281
  const final = ec.finalNewline === true && out !== "" && !out.endsWith("\n") ? `${out}\n` : out;
1267
1282
  return finishWrite(p, final, ec.eol, args.content);
1268
1283
  },
@@ -992,7 +992,7 @@ export function buildApp(master) {
992
992
  }
993
993
  }
994
994
  else if (body.status)
995
- await a.setGoalStatus(body.status);
995
+ await a.setGoalStatus(body.status, "operator");
996
996
  else
997
997
  return c.json({ error: "text or status required" }, 400);
998
998
  return c.json({ ok: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.139",
3
+ "version": "0.37.141",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",