@testchimp/cli 0.1.59 → 0.1.60

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.
@@ -1546,9 +1546,7 @@ export async function runChimphands(opts) {
1546
1546
  syncLiveSse(attached);
1547
1547
  })
1548
1548
  : () => { };
1549
- const stopTunnel = runtimeId && attachUrl
1550
- ? startTunnelWorker(backend, apiKey, runtimeId, attachUrl)
1551
- : () => { };
1549
+ let stopTunnel = () => { };
1552
1550
  const userId = bootStr(boot, "chimphands_service_account_user_id", "chimphandsServiceAccountUserId");
1553
1551
  if (userId) {
1554
1552
  process.env.TESTCHIMP_USER_ID = userId;
@@ -1634,6 +1632,13 @@ export async function runChimphands(opts) {
1634
1632
  // Polling is best-effort when inbound SSE misses an event.
1635
1633
  }
1636
1634
  };
1635
+ const seenWorktreeWriteRequestIds = new Set();
1636
+ const handleUserFileEdit = (edit) => {
1637
+ if (seenWorktreeWriteRequestIds.has(edit.requestId))
1638
+ return;
1639
+ seenWorktreeWriteRequestIds.add(edit.requestId);
1640
+ void applyUserFileEdit(backend, apiKey, sessionId, edit, () => agentTurnInProgress);
1641
+ };
1637
1642
  const postEvent = (role, content, opts) => {
1638
1643
  const bodyOpts = { ...opts };
1639
1644
  if (opencodeSessionId && !bodyOpts.opencodeSessionId) {
@@ -1686,11 +1691,14 @@ export async function runChimphands(opts) {
1686
1691
  }
1687
1692
  }
1688
1693
  },
1689
- onUserFileEdit: (edit) => {
1690
- void applyUserFileEdit(backend, apiKey, sessionId, edit, () => agentTurnInProgress);
1691
- },
1694
+ onUserFileEdit: handleUserFileEdit,
1692
1695
  shouldRun: () => sessionActive,
1693
1696
  });
1697
+ if (runtimeId && attachUrl) {
1698
+ stopTunnel = startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, {
1699
+ onUserFileEdit: handleUserFileEdit,
1700
+ });
1701
+ }
1694
1702
  const shutdownRuntime = async () => {
1695
1703
  sessionActive = false;
1696
1704
  stopInbound();
@@ -1970,7 +1978,7 @@ async function commitAndPushDirtyWorktree(message) {
1970
1978
  console.error(`ChimpHands commit-before-idle failed: ${err instanceof Error ? err.message : String(err)}`);
1971
1979
  }
1972
1980
  }
1973
- function startTunnelWorker(backend, apiKey, runtimeId, attachUrl) {
1981
+ function startTunnelWorker(backend, apiKey, runtimeId, attachUrl, sessionId, handlers) {
1974
1982
  let stopped = false;
1975
1983
  const base = attachUrl.replace(/\/$/, "");
1976
1984
  let ws = null;
@@ -2101,6 +2109,21 @@ function startTunnelWorker(backend, apiKey, runtimeId, attachUrl) {
2101
2109
  socket.send(JSON.stringify({ type: "pong" }));
2102
2110
  return;
2103
2111
  }
2112
+ if (frame.type === "inbound_event" && frame.event === "user_file_edit" && frame.data) {
2113
+ const edit = frame.data;
2114
+ if (edit.sessionId && edit.sessionId !== sessionId) {
2115
+ return;
2116
+ }
2117
+ const requestId = edit.requestId || edit.request_id;
2118
+ if (requestId && edit.path) {
2119
+ handlers?.onUserFileEdit?.({
2120
+ requestId,
2121
+ path: edit.path,
2122
+ content: edit.content ?? "",
2123
+ });
2124
+ }
2125
+ return;
2126
+ }
2104
2127
  if (frame.type === "http_request" || frame.requestId) {
2105
2128
  void handleHttpRequest(socket, frame);
2106
2129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testchimp/cli",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "TestChimp CLI and MCP server — coverage, plans, EaaS, TrueCoverage, API operations (calls /api/mcp/*)",
5
5
  "type": "module",
6
6
  "main": "dist/bin/testchimp.js",