teapot-coding-agent 0.29.35 → 0.29.37

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.
@@ -1398,12 +1398,32 @@ export class Agent {
1398
1398
  * normalized text; unknown items are reported back instead of silently
1399
1399
  * dropped. Returns a short human-readable summary for the tool result.
1400
1400
  */
1401
+ /**
1402
+ * Apply surgical changes to todo.md.
1403
+ *
1404
+ * Each entry names an item by its exact (normalised) text and says what to do with it:
1405
+ * - `done` / `reopen` / `remove` act on an EXISTING checkbox line;
1406
+ * - `add` appends a new unchecked line, even when nothing matches.
1407
+ *
1408
+ * `action` is optional and defaults to `done`, so every existing caller and every model
1409
+ * that only sends `{item, done}` keeps working.
1410
+ *
1411
+ * Why not whole-list replacement, which Codex (`update_plan`) and DeepSeek Harness
1412
+ * (`todo/write`) both use: `todo.md` is a file the OPERATOR also edits, and it holds
1413
+ * headings, notes and prose — not only checkboxes. A model re-emitting "the list" would
1414
+ * silently drop anything it did not repeat, which is exactly the data loss `set_memory`
1415
+ * caused before `#48` (measured: 1028 → 83 bytes). The `content` argument still exists
1416
+ * for a deliberate restructure.
1417
+ */
1401
1418
  async updateTodoItems(updates, by = "agent") {
1402
1419
  const norm = (s) => s.replace(/\s+/g, " ").trim().toLowerCase();
1403
1420
  const lines = this.todo.split("\n");
1404
1421
  let matched = 0;
1422
+ let added = 0;
1423
+ let removed = 0;
1405
1424
  const unmatched = [];
1406
1425
  for (const u of updates) {
1426
+ const action = u.action ?? (u.done === false ? "reopen" : "done");
1407
1427
  const target = norm(u.item);
1408
1428
  // find the LAST matching checkbox line (later duplicates win)
1409
1429
  let idx = -1;
@@ -1416,26 +1436,57 @@ export class Agent {
1416
1436
  break;
1417
1437
  }
1418
1438
  }
1439
+ if (action === "add") {
1440
+ // An ADD repeats: the caller may add several items with the same wording, and
1441
+ // refusing because one already exists would make "add" unpredictable. But adding
1442
+ // the SAME text twice in one call is a mistake, so collapse it.
1443
+ if (idx !== -1) {
1444
+ unmatched.push(`${u.item} (already present — not added twice)`);
1445
+ continue;
1446
+ }
1447
+ lines.push(`- [ ] ${u.item.trim()}`);
1448
+ added++;
1449
+ continue;
1450
+ }
1419
1451
  if (idx === -1) {
1420
1452
  unmatched.push(u.item);
1421
1453
  continue;
1422
1454
  }
1423
- lines[idx] = lines[idx].replace(/^(.* \[)[ xX](\].*)$/, (_s, a, b) => `${a}${u.done ? "x" : " "}${b}`);
1455
+ if (action === "remove") {
1456
+ lines.splice(idx, 1);
1457
+ removed++;
1458
+ continue;
1459
+ }
1460
+ const checked = action === "done";
1461
+ lines[idx] = lines[idx].replace(/^(.* \[)[ xX](\].*)$/, (_s, a, b) => `${a}${checked ? "x" : " "}${b}`);
1424
1462
  matched++;
1425
1463
  }
1426
- if (matched > 0) {
1464
+ if (matched > 0 || added > 0 || removed > 0) {
1465
+ // trailing blank lines from a removal are tidied so the file does not grow a gap
1466
+ while (lines.length > 1 && lines[lines.length - 1].trim() === "" && lines[lines.length - 2].trim() === "")
1467
+ lines.pop();
1427
1468
  this.todo = lines.join("\n");
1428
1469
  await fs.writeFile(this.todoFile, this.todo, "utf8");
1429
1470
  await this.log.append("todo", this.currentSession, this.currentBranch, {
1430
1471
  event: "items",
1431
1472
  by,
1432
1473
  matched,
1474
+ ...(added ? { added } : {}),
1475
+ ...(removed ? { removed } : {}),
1433
1476
  ...(unmatched.length ? { unknown: unmatched } : {}),
1434
1477
  });
1435
1478
  }
1436
- const parts = [`${matched} item(s) updated`];
1479
+ const parts = [];
1480
+ if (matched)
1481
+ parts.push(`${matched} item(s) updated`);
1482
+ if (added)
1483
+ parts.push(`${added} item(s) added`);
1484
+ if (removed)
1485
+ parts.push(`${removed} item(s) removed`);
1486
+ if (!parts.length)
1487
+ parts.push("nothing changed");
1437
1488
  if (unmatched.length)
1438
- parts.push(`NOT FOUND in todo.md: ${unmatched.map((s) => `"${s}"`).join(", ")} — check get_todo and retry with the exact wording`);
1489
+ 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`);
1439
1490
  return parts.join(". ");
1440
1491
  }
1441
1492
  async setGoalStatus(status) {
@@ -2489,13 +2540,23 @@ export class Agent {
2489
2540
  }
2490
2541
  if (call.function.name === "set_todo") {
2491
2542
  const a = safeParse(call.function.arguments);
2492
- // Preferred: surgical checkbox updates — no full rewrite, no risk
2493
- // of mangling unrelated sections, cheap enough to do mid-task.
2543
+ // Surgical item changes — no full rewrite, so the operator's own headings and
2544
+ // notes in todo.md survive. `action` decides what to do; `done` is kept as
2545
+ // shorthand so a model that only sends {item, done} still works.
2546
+ const ACTIONS = new Set(["done", "reopen", "add", "remove"]);
2494
2547
  const updates = Array.isArray(a.updates)
2495
2548
  ? a.updates
2496
2549
  .map((u) => {
2497
2550
  const o = (u ?? {});
2498
- return { item: String(o.item ?? ""), done: o.done !== false };
2551
+ const raw = String(o.action ?? "");
2552
+ const action = ACTIONS.has(raw)
2553
+ ? raw
2554
+ : undefined;
2555
+ return {
2556
+ item: String(o.item ?? ""),
2557
+ done: o.done !== false,
2558
+ ...(action ? { action } : {}),
2559
+ };
2499
2560
  })
2500
2561
  .filter((u) => u.item.trim())
2501
2562
  : [];
@@ -2506,7 +2567,8 @@ export class Agent {
2506
2567
  }
2507
2568
  const content = String(a.content ?? "").slice(0, 32_000);
2508
2569
  if (!content.trim()) {
2509
- await this.answerMeta(call, "nothing to do: pass updates:[{item,done}] to check items off, or content to replace the whole list");
2570
+ await this.answerMeta(call, "nothing to do: pass updates:[{item, action}] to change items " +
2571
+ "(action: done | reopen | add | remove), or content to replace the whole list");
2510
2572
  continue;
2511
2573
  }
2512
2574
  await this.setTodo(content, "agent");
@@ -4279,20 +4341,28 @@ function allToolSpecs() {
4279
4341
  type: "function",
4280
4342
  function: {
4281
4343
  name: "set_todo",
4282
- description: "Update the operator-visible task list (todo.md). PREFERRED: pass updates to check specific " +
4283
- "items off as you finish them — cheap, surgical, no risk of mangling other sections. Only pass " +
4284
- "content to rewrite the whole list when restructuring it. Call this promptly on every item you complete.",
4344
+ description: "Update the operator-visible task list (todo.md). PREFERRED: pass updates to change specific " +
4345
+ "items — cheap, surgical, no risk of mangling other sections or the operator's own notes. " +
4346
+ "Each entry names an item by its exact text and says what to do: done (default), reopen, " +
4347
+ "add, or remove. Only pass content to rewrite the whole list when restructuring it. " +
4348
+ "Call this promptly on every item you complete.",
4285
4349
  parameters: {
4286
4350
  type: "object",
4287
4351
  properties: {
4288
4352
  updates: {
4289
4353
  type: "array",
4290
- description: "surgical checkbox flips — match items by their exact text in todo.md",
4354
+ description: "surgical item changes — match existing items by their exact text in todo.md",
4291
4355
  items: {
4292
4356
  type: "object",
4293
4357
  properties: {
4294
- item: { type: "string", description: "checkbox item text (without the \"- [ ]\" marker)" },
4295
- done: { type: "boolean", description: "true = check off, false = reopen (default true)" },
4358
+ item: { type: "string", description: "item text (without the \"- [ ]\" marker)" },
4359
+ action: {
4360
+ type: "string",
4361
+ enum: ["done", "reopen", "add", "remove"],
4362
+ description: "done = check off (default), reopen = uncheck, add = append a new item " +
4363
+ "(works even when nothing matches), remove = delete the line",
4364
+ },
4365
+ done: { type: "boolean", description: "shorthand for action done/reopen (default true)" },
4296
4366
  },
4297
4367
  required: ["item"],
4298
4368
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.29.35",
3
+ "version": "0.29.37",
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",