chatroom-cli 1.58.4 → 1.58.5

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.
package/dist/index.js CHANGED
@@ -77541,13 +77541,28 @@ var init_backlog2 = __esm(() => {
77541
77541
  STALENESS_THRESHOLD_MS = 7 * 24 * 60 * 60 * 1000;
77542
77542
  });
77543
77543
 
77544
+ // ../../services/backend/prompts/attachments/xml.ts
77545
+ function escapeXmlText(value) {
77546
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
77547
+ }
77548
+ function escapeXmlAttribute(value) {
77549
+ return escapeXmlText(value).replace(/"/g, "&quot;");
77550
+ }
77551
+ function xmlTextElement(tag, content, indent = " ") {
77552
+ if (!content.includes(`
77553
+ `)) {
77554
+ return [`${indent}<${tag}>${escapeXmlText(content)}</${tag}>`];
77555
+ }
77556
+ return [`${indent}<${tag}>`, escapeXmlText(content), `${indent}</${tag}>`];
77557
+ }
77558
+
77544
77559
  // ../../services/backend/prompts/attachments/render-delivery-attachments.ts
77545
77560
  function renderSnippetAttachment(snippet) {
77546
77561
  return [
77547
- ` <attachment reference="${snippet.reference}">`,
77548
- ` <snippet file-source="${snippet.fileSource}">`,
77562
+ ` <attachment type="snippet" reference="${escapeXmlAttribute(snippet.reference)}">`,
77563
+ ` <snippet file-source="${escapeXmlAttribute(snippet.fileSource)}">`,
77549
77564
  ` <user-selected-content>`,
77550
- snippet.selectedContent,
77565
+ escapeXmlText(snippet.selectedContent),
77551
77566
  ` </user-selected-content>`,
77552
77567
  ` </snippet>`,
77553
77568
  ` </attachment>`
@@ -77556,10 +77571,9 @@ function renderSnippetAttachment(snippet) {
77556
77571
  function renderBacklogAttachments(items, ctx) {
77557
77572
  const lines = [];
77558
77573
  for (const item of items) {
77559
- lines.push(` <attachment type="backlog-item">`);
77560
- lines.push(` - [${item.status.toUpperCase()}] ${item.content}`);
77561
- lines.push(` ID: ${item._id}`);
77562
- lines.push(` <hint>Work on this item. When done: chatroom backlog mark-for-review --chatroom-id="${ctx.chatroomId}" --role="${ctx.role}" --backlog-item-id=${item._id}</hint>`);
77574
+ lines.push(` <attachment type="backlog" backlog-item-id="${escapeXmlAttribute(item._id)}">`);
77575
+ lines.push(...xmlTextElement("content", item.content, " "));
77576
+ lines.push(` <hint>Work on this item. When done: chatroom backlog mark-for-review --chatroom-id="${escapeXmlAttribute(ctx.chatroomId)}" --role="${escapeXmlAttribute(ctx.role)}" --backlog-item-id=${item._id}</hint>`);
77563
77577
  lines.push(` </attachment>`);
77564
77578
  }
77565
77579
  return lines;
@@ -77571,19 +77585,51 @@ function renderSnippetAttachments(snippets) {
77571
77585
  }
77572
77586
  return lines;
77573
77587
  }
77588
+ function renderTaskAttachments(items, _ctx) {
77589
+ const lines = [];
77590
+ for (const item of items) {
77591
+ lines.push(` <attachment type="task" task-id="${escapeXmlAttribute(item._id)}">`);
77592
+ lines.push(...xmlTextElement("content", item.content, " "));
77593
+ lines.push(` <hint>Referenced task attached by user.</hint>`);
77594
+ lines.push(` </attachment>`);
77595
+ }
77596
+ return lines;
77597
+ }
77598
+ function renderMessageAttachments(items) {
77599
+ const lines = [];
77600
+ for (const item of items) {
77601
+ lines.push(` <attachment type="message" message-id="${escapeXmlAttribute(item._id)}">`);
77602
+ lines.push(...xmlTextElement("sender-role", item.senderRole, " "));
77603
+ lines.push(...xmlTextElement("content", item.content, " "));
77604
+ lines.push(` </attachment>`);
77605
+ }
77606
+ return lines;
77607
+ }
77574
77608
  function renderDeliveryAttachmentsBlock(input, ctx) {
77575
77609
  const backlogLines = input.attachedBacklogItems?.length ? DELIVERY_ATTACHMENT_RENDERERS.backlog(input.attachedBacklogItems, ctx) : [];
77610
+ const taskLines = input.attachedTasks?.length ? DELIVERY_ATTACHMENT_RENDERERS.task(input.attachedTasks, ctx) : [];
77611
+ const messageLines = input.attachedMessages?.length ? DELIVERY_ATTACHMENT_RENDERERS.message(input.attachedMessages, ctx) : [];
77576
77612
  const snippetLines = input.attachedSnippets?.length ? DELIVERY_ATTACHMENT_RENDERERS.snippet(input.attachedSnippets, ctx) : [];
77577
- if (backlogLines.length === 0 && snippetLines.length === 0)
77613
+ if (backlogLines.length === 0 && taskLines.length === 0 && messageLines.length === 0 && snippetLines.length === 0) {
77578
77614
  return [];
77579
- return ["", "<attachments>", ...backlogLines, ...snippetLines, "</attachments>"];
77615
+ }
77616
+ return [
77617
+ "",
77618
+ "<attachments>",
77619
+ ...backlogLines,
77620
+ ...taskLines,
77621
+ ...messageLines,
77622
+ ...snippetLines,
77623
+ "</attachments>"
77624
+ ];
77580
77625
  }
77581
77626
  var DELIVERY_ATTACHMENT_RENDERERS;
77582
77627
  var init_render_delivery_attachments = __esm(() => {
77583
77628
  DELIVERY_ATTACHMENT_RENDERERS = {
77584
77629
  backlog: renderBacklogAttachments,
77585
77630
  snippet: renderSnippetAttachments,
77586
- message: () => []
77631
+ message: renderMessageAttachments,
77632
+ task: renderTaskAttachments
77587
77633
  };
77588
77634
  });
77589
77635
 
@@ -77597,7 +77643,9 @@ function detectBacklogDivergence(contextContent, attachedIds) {
77597
77643
  function renderAttachments(input, chatroomId, role) {
77598
77644
  return renderDeliveryAttachmentsBlock({
77599
77645
  attachedBacklogItems: input.attachedBacklogItems,
77600
- attachedSnippets: input.attachedSnippets
77646
+ attachedSnippets: input.attachedSnippets,
77647
+ attachedTasks: input.attachedTasks,
77648
+ attachedMessages: input.attachedMessages
77601
77649
  }, { chatroomId, role, mode: "task-read" });
77602
77650
  }
77603
77651
  function renderDivergenceWarnings(input) {
@@ -77692,7 +77740,9 @@ function buildTaskPromptFromReadResult(result, chatroomId, role) {
77692
77740
  role,
77693
77741
  context: result.context && typeof result.context === "object" ? result.context : undefined,
77694
77742
  attachedBacklogItems: Array.isArray(result.attachedBacklogItems) ? result.attachedBacklogItems : undefined,
77695
- attachedSnippets: Array.isArray(result.attachedSnippets) ? result.attachedSnippets : undefined
77743
+ attachedSnippets: Array.isArray(result.attachedSnippets) ? result.attachedSnippets : undefined,
77744
+ attachedTasks: Array.isArray(result.attachedTasks) ? result.attachedTasks : undefined,
77745
+ attachedMessages: Array.isArray(result.attachedMessages) ? result.attachedMessages : undefined
77696
77746
  });
77697
77747
  }
77698
77748
  function handleTaskReadError(err) {
@@ -106119,4 +106169,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
106119
106169
  });
106120
106170
  program2.parse();
106121
106171
 
106122
- //# debugId=0080C69D49B8FE3164756E2164756E21
106172
+ //# debugId=2DFDF6706DFDE76764756E2164756E21