replicas-cli 0.3.402 → 0.3.405

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.cjs +89 -4
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -26456,7 +26456,85 @@ function removeTag(text4, tag) {
26456
26456
  function stripReplicasInstructionBlock(text4) {
26457
26457
  return removeTag(text4, REPLICAS_INSTRUCTIONS_TAG);
26458
26458
  }
26459
- var REPLICAS_INSTRUCTIONS_TAG, MOTHERSHIP_INSTRUCTIONS_TAG, INSTRUCTIONS_OPEN, INSTRUCTIONS_CLOSE, MOTHERSHIP_EVENT_CHAT_NOTE, BOARD_ANSWER_NOTE, BOARD_RULES, MOTHERSHIP_INSTRUCTIONS_BLOCK, T, SCOUT_LINEAR_RULES, SCOUT_MUTED_RULES, SCOUT_PRIOR_UNTAGGED_RULES, SCOUT_JOINED_RULES, SCOUT_REACTION_RULES;
26459
+ function stripInstructionBlocksOutside(text4, ranges) {
26460
+ const outside = (index) => !ranges.some(([start, end]) => index >= start && index < end);
26461
+ let kept = "";
26462
+ let from = 0;
26463
+ for (let open4 = text4.indexOf(INSTRUCTIONS_OPEN); open4 !== -1; open4 = text4.indexOf(INSTRUCTIONS_OPEN, Math.max(from, open4 + 1))) {
26464
+ if (!outside(open4)) continue;
26465
+ let close = text4.indexOf(INSTRUCTIONS_CLOSE, open4);
26466
+ while (close !== -1 && !outside(close)) close = text4.indexOf(INSTRUCTIONS_CLOSE, close + 1);
26467
+ if (close === -1) break;
26468
+ kept += text4.slice(from, open4);
26469
+ from = close + INSTRUCTIONS_CLOSE.length;
26470
+ }
26471
+ return (kept + text4.slice(from)).trim();
26472
+ }
26473
+ function stripAgentInstructionBlocks(text4) {
26474
+ if (!text4.includes(INSTRUCTIONS_OPEN)) return text4.trim();
26475
+ const quoted = [];
26476
+ const pair = (start, end) => {
26477
+ const at2 = [];
26478
+ const length = [];
26479
+ const run2 = /`+/g;
26480
+ run2.lastIndex = start;
26481
+ for (let found = run2.exec(text4); found && found.index < end; found = run2.exec(text4)) {
26482
+ at2.push(found.index);
26483
+ length.push(found[0].length);
26484
+ }
26485
+ const next = new Array(at2.length).fill(-1);
26486
+ const seen = /* @__PURE__ */ new Map();
26487
+ for (let i = at2.length - 1; i >= 0; i--) {
26488
+ next[i] = seen.get(length[i]) ?? -1;
26489
+ seen.set(length[i], i);
26490
+ }
26491
+ for (let i = 0; i < at2.length; i = next[i] === -1 ? i + 1 : next[i] + 1) {
26492
+ if (next[i] !== -1) quoted.push([at2[i], at2[next[i]] + length[next[i]]]);
26493
+ }
26494
+ };
26495
+ const tags = [...text4.matchAll(new RegExp(`</?${REPLICAS_INSTRUCTIONS_TAG}>`, "g"))].map((tag) => tag.index ?? 0);
26496
+ const paragraphs = /* @__PURE__ */ new Set();
26497
+ const spans = (from, to) => {
26498
+ for (const tag of tags) {
26499
+ if (tag < from || tag >= to) continue;
26500
+ let start = text4.lastIndexOf("\n", tag - 1) + 1;
26501
+ for (let previous = text4.lastIndexOf("\n", start - 2) + 1; start > from && text4.slice(previous, start - 1).trim(); previous = text4.lastIndexOf("\n", start - 2) + 1) start = previous;
26502
+ start = Math.max(start, from);
26503
+ if (paragraphs.has(start)) continue;
26504
+ paragraphs.add(start);
26505
+ const blank = /\n[ \t]*\n/g;
26506
+ blank.lastIndex = tag;
26507
+ const end = Math.min(to, blank.exec(text4)?.index ?? to);
26508
+ pair(start, end);
26509
+ }
26510
+ };
26511
+ let fence = null;
26512
+ let prose = 0;
26513
+ let at = 0;
26514
+ for (let end = 0; at < text4.length; at = end) {
26515
+ end = text4.indexOf("\n", at) + 1 || text4.length;
26516
+ const line = text4.slice(at, end);
26517
+ const prefix = new RegExp(`^(?: {0,3}>[ \\t]?)${fence ? `{0,${fence.depth}}` : "*"}`).exec(line)?.[0] ?? "";
26518
+ const quote = line.slice(prefix.length);
26519
+ const opener = fence ? quote : quote.replace(/^\s*(?:[-*+]|\d+[.)])\s+/, "");
26520
+ const found = fenceMarker(opener);
26521
+ const marker = found && !(found[0] === "`" && opener.slice(opener.indexOf(found) + found.length).includes("`")) ? found : void 0;
26522
+ if (fence) {
26523
+ if (fenceMarker(quote.trimEnd(), fence.marker)) {
26524
+ quoted.push([fence.start, end]);
26525
+ fence = null;
26526
+ prose = end;
26527
+ }
26528
+ } else if (marker) {
26529
+ spans(prose, at);
26530
+ fence = { marker, start: at, depth: (prefix.match(/>/g) ?? []).length };
26531
+ } else if (line[0] === " " || line.startsWith(" ")) quoted.push([at, end]);
26532
+ }
26533
+ if (fence) quoted.push([fence.start, text4.length]);
26534
+ else spans(prose, text4.length);
26535
+ return stripInstructionBlocksOutside(text4, quoted);
26536
+ }
26537
+ var REPLICAS_INSTRUCTIONS_TAG, MOTHERSHIP_INSTRUCTIONS_TAG, fenceMarker, INSTRUCTIONS_OPEN, INSTRUCTIONS_CLOSE, MOTHERSHIP_EVENT_CHAT_NOTE, BOARD_ANSWER_NOTE, BOARD_RULES, MOTHERSHIP_INSTRUCTIONS_BLOCK, T, SCOUT_LINEAR_RULES, SCOUT_MUTED_RULES, SCOUT_PRIOR_UNTAGGED_RULES, SCOUT_JOINED_RULES, SCOUT_REACTION_RULES;
26460
26538
  var init_prompts = __esm({
26461
26539
  "../shared/src/prompts.ts"() {
26462
26540
  "use strict";
@@ -26473,6 +26551,10 @@ var init_prompts = __esm({
26473
26551
  init_slack_response_style();
26474
26552
  REPLICAS_INSTRUCTIONS_TAG = "replicas_instructions";
26475
26553
  MOTHERSHIP_INSTRUCTIONS_TAG = "multitask_instructions";
26554
+ fenceMarker = (line, open4) => {
26555
+ const marker = (open4 ? /^ {0,3}(`{3,}|~{3,})[ \t]*$/ : /^ {0,3}(`{3,}|~{3,})/).exec(line)?.[1];
26556
+ return !open4 || marker?.[0] === open4[0] && marker.length >= open4.length ? marker : void 0;
26557
+ };
26476
26558
  INSTRUCTIONS_OPEN = `<${REPLICAS_INSTRUCTIONS_TAG}>`;
26477
26559
  INSTRUCTIONS_CLOSE = `</${REPLICAS_INSTRUCTIONS_TAG}>`;
26478
26560
  MOTHERSHIP_EVENT_CHAT_NOTE = `If a message the user typed in this turn is still unanswered, your final reply answers it and they see it. Otherwise they don't see text you write in this turn: if it brings something they asked for, or a blocker that needs them, send it with ${REPLICAS_MCP_TOOLS.sendToChat}; then update the board if its order, notes or overview changed, and end with a one-line note.`;
@@ -26538,7 +26620,7 @@ function extractMothershipEvents(text4) {
26538
26620
  if (!attributes.kind || !attributes.id || !attributes.agent_id) return [];
26539
26621
  const kind = MOTHERSHIP_EVENT_KINDS.find((candidate) => candidate === attributes.kind) ?? UNKNOWN_EVENT_KIND;
26540
26622
  const [summary, ...rest] = match[2].replaceAll(`<\\/${TAG}`, `</${TAG}`).split("\n\n");
26541
- const detail = rest.join("\n\n").trim();
26623
+ const detail = stripAgentInstructionBlocks(rest.join("\n\n"));
26542
26624
  return [{
26543
26625
  id: attributes.id,
26544
26626
  at: attributes.at ?? "",
@@ -26556,6 +26638,9 @@ function parseMothershipEvents(text4) {
26556
26638
  const events = extractMothershipEvents(text4);
26557
26639
  return events.length > 0 && text4.replace(BLOCK, "").replaceAll(MERGED_MESSAGE_SEPARATOR.trim(), "").trim() === "" ? events : null;
26558
26640
  }
26641
+ function stripMothershipEventNotes(content) {
26642
+ return stripInstructionBlocksOutside(content, [...content.matchAll(BLOCK)].map((block) => [block.index, block.index + block[0].length]));
26643
+ }
26559
26644
  var MOTHERSHIP_EVENT_KINDS, UNKNOWN_EVENT_KIND, MOTHERSHIP_EVENT_TYPE, mothershipEventSchema, TAG, BLOCK, ATTRIBUTE, unescapeAttribute;
26560
26645
  var init_mothership_events = __esm({
26561
26646
  "../shared/src/mothership-events.ts"() {
@@ -37146,7 +37231,7 @@ function filterDisplayMessages(messages, provider2) {
37146
37231
  if (msg.type !== "user") return [msg];
37147
37232
  let stripped = strippedUserContents.get(msg.content);
37148
37233
  if (!stripped) {
37149
- stripped = stripAttachmentNote(stripReplicasInstructionBlock(msg.content).trim());
37234
+ stripped = stripAttachmentNote(stripMothershipEventNotes(msg.content));
37150
37235
  if (strippedUserContents.size >= 5e3) strippedUserContents.clear();
37151
37236
  strippedUserContents.set(msg.content, stripped);
37152
37237
  }
@@ -37852,7 +37937,7 @@ var CLI_VERSION;
37852
37937
  var init_cli_version = __esm({
37853
37938
  "../shared/src/cli-version.ts"() {
37854
37939
  "use strict";
37855
- CLI_VERSION = "0.3.402";
37940
+ CLI_VERSION = "0.3.405";
37856
37941
  }
37857
37942
  });
37858
37943
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.402",
3
+ "version": "0.3.405",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {