@groupchatai/claude-runner 0.4.10 → 0.4.12

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.
Files changed (2) hide show
  1. package/dist/index.js +46 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -79,6 +79,44 @@ var GroupChatAgentClient = class {
79
79
  return this.request("POST", `/runs/${runId}/comment`, { body });
80
80
  }
81
81
  };
82
+ function buildResumedPrompt(detail, agentUserId) {
83
+ const comments = detail.activity.filter(
84
+ (a) => a.type === "comment" && a.body && a.body.trim().length > 0
85
+ );
86
+ const agentCommentIndices = [];
87
+ for (let i = 0; i < comments.length; i++) {
88
+ if (comments[i].userId === agentUserId) {
89
+ agentCommentIndices.push(i);
90
+ }
91
+ }
92
+ let cutoffIdx = -1;
93
+ if (agentCommentIndices.length >= 2) {
94
+ cutoffIdx = agentCommentIndices[agentCommentIndices.length - 2];
95
+ } else if (agentCommentIndices.length === 1) {
96
+ cutoffIdx = agentCommentIndices[0];
97
+ }
98
+ const newComments = comments.slice(cutoffIdx + 1).filter((c) => c.userId !== agentUserId);
99
+ const parts = [];
100
+ if (newComments.length > 0) {
101
+ parts.push("New comments since your last response:");
102
+ for (const c of newComments) {
103
+ const author = c.userName ?? "Someone";
104
+ parts.push(`
105
+ **${author}**:
106
+ ${c.body}`);
107
+ }
108
+ }
109
+ if (detail.lastFollowUpMessage && detail.lastFollowUpMessage !== "Continue working on this task.") {
110
+ parts.push(`
111
+ Follow-up request: ${detail.lastFollowUpMessage}`);
112
+ }
113
+ if (parts.length === 0) {
114
+ parts.push(
115
+ "The user has asked you to continue working on this task. Check the conversation history and address any outstanding requests."
116
+ );
117
+ }
118
+ return parts.join("\n");
119
+ }
82
120
  function buildClaudePrompt(detail, repoResolved) {
83
121
  const parts = [];
84
122
  parts.push(`# Task: ${detail.task.title}`);
@@ -167,8 +205,7 @@ Due: ${dueStr}`);
167
205
  ...prRules,
168
206
  "- NEVER run `gh pr merge`. Do NOT merge any PR.",
169
207
  "- NEVER run `gh pr close`. Do NOT close any PR.",
170
- "- NEVER run `git push --force` or `git push -f`. No force pushes.",
171
- "- When you are done, provide a clear summary of what you accomplished."
208
+ "- NEVER run `git push --force` or `git push -f`. No force pushes."
172
209
  ].join("\n")
173
210
  );
174
211
  return parts.join("\n");
@@ -197,13 +234,13 @@ function wrapLines(tag, pad, text, color) {
197
234
  const rest = lines.slice(1).map((l) => `${pad}${color}${l}${C.reset}`);
198
235
  return [first, ...rest].join("\n");
199
236
  }
200
- function formatStreamEvent(event, pid) {
237
+ function formatStreamEvent(event, pid, isResumed) {
201
238
  const tag = pidTag(pid);
202
239
  const pad = padForTag(pid);
203
240
  switch (event.type) {
204
241
  case "system":
205
242
  if (event.subtype === "init") {
206
- let line = `${tag} ${C.dim}session started`;
243
+ let line = `${tag} ${C.dim}session ${isResumed ? "resumed" : "started"}`;
207
244
  if (event.session_id) line += ` (${event.session_id})`;
208
245
  line += C.reset;
209
246
  return line;
@@ -488,7 +525,7 @@ function spawnClaudeCode(prompt, config, runOptions, resumeSessionId, cwdOverrid
488
525
  if (event.type === "result") lastResultJson = trimmed;
489
526
  checkEventForPrUrl(event);
490
527
  if (config.verbose) {
491
- const formatted = formatStreamEvent(event, pid);
528
+ const formatted = formatStreamEvent(event, pid, !!resumeSessionId);
492
529
  if (formatted) console.log(formatted);
493
530
  }
494
531
  } catch {
@@ -621,6 +658,7 @@ function runShellCommand(cmd, args, cwd) {
621
658
  });
622
659
  }
623
660
  var sessionCache = /* @__PURE__ */ new Map();
661
+ var currentAgentUserId = "";
624
662
  var activeProcesses = /* @__PURE__ */ new Map();
625
663
  var stoppedRunIds = /* @__PURE__ */ new Set();
626
664
  function stopActiveProcess(runId) {
@@ -1003,10 +1041,8 @@ async function processRun(client, run, config, worktreeDir, detail, runBaseDir,
1003
1041
  const cachedSessionId = sessionCache.get(run.taskId) ?? detail.lastSessionId;
1004
1042
  const isFollowUp = cachedSessionId !== void 0;
1005
1043
  let effectivePrompt;
1006
- if (isFollowUp && detail.lastFollowUpMessage) {
1007
- effectivePrompt = detail.lastFollowUpMessage;
1008
- } else if (isFollowUp) {
1009
- effectivePrompt = prompt;
1044
+ if (isFollowUp && cachedSessionId) {
1045
+ effectivePrompt = buildResumedPrompt(detail, currentAgentUserId);
1010
1046
  } else {
1011
1047
  effectivePrompt = prompt;
1012
1048
  }
@@ -1670,6 +1706,7 @@ async function main() {
1670
1706
  console.error("Failed to authenticate:", errMsg(err));
1671
1707
  process.exit(1);
1672
1708
  }
1709
+ currentAgentUserId = me.agentUserId;
1673
1710
  console.log(`
1674
1711
  \u{1F916} Agent Runner \u2014 ${me.name}`);
1675
1712
  console.log(` Owner: ${me.ownerName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@groupchatai/claude-runner",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Run GroupChat AI agent tasks locally with Claude Code",
5
5
  "type": "module",
6
6
  "bin": {