adhdev 0.9.42 → 0.9.44

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
@@ -11817,7 +11817,8 @@ var provider_cli_adapter_exports = {};
11817
11817
  __export(provider_cli_adapter_exports, {
11818
11818
  ProviderCliAdapter: () => ProviderCliAdapter,
11819
11819
  appendBoundedText: () => appendBoundedText,
11820
- normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime
11820
+ normalizeCliProviderForRuntime: () => normalizeCliProviderForRuntime,
11821
+ sanitizeCliStandardMessageContent: () => sanitizeCliStandardMessageContent
11821
11822
  });
11822
11823
  function normalizeComparableTranscriptText(value) {
11823
11824
  return sanitizeTerminalText(String(value || "")).replace(/\s+/g, " ").trim();
@@ -11857,7 +11858,63 @@ function appendBoundedText(current, chunk, maxChars) {
11857
11858
  if (current.length <= keepFromCurrent) return current + chunk;
11858
11859
  return current.slice(-keepFromCurrent) + chunk;
11859
11860
  }
11860
- var os12, ProviderCliAdapter;
11861
+ function isLikelyCommittedActivityPrefixContinuation(line) {
11862
+ const trimmed = String(line || "").trim();
11863
+ if (!trimmed) return false;
11864
+ if (COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(trimmed)) return false;
11865
+ if (/\s/.test(trimmed)) return false;
11866
+ if (/[가-힣]/.test(trimmed)) return false;
11867
+ if (trimmed.length > 96) return false;
11868
+ return /^[A-Za-z0-9_./:@+%=-]+$/.test(trimmed);
11869
+ }
11870
+ function parseCommittedActivityPrefixBlock(lines, index) {
11871
+ const first = String(lines[index] || "").trim();
11872
+ if (!COMMITTED_ACTIVITY_PREFIX_BLOCK_RE.test(first)) return null;
11873
+ const parts = [first];
11874
+ let nextIndex = index + 1;
11875
+ while (nextIndex < lines.length && isLikelyCommittedActivityPrefixContinuation(lines[nextIndex])) {
11876
+ parts.push(String(lines[nextIndex] || "").trim());
11877
+ nextIndex += 1;
11878
+ }
11879
+ return { label: parts.join(""), nextIndex };
11880
+ }
11881
+ function sanitizeCliStandardMessageContent(content) {
11882
+ const source = String(content || "").trim();
11883
+ if (!source) return "";
11884
+ const lines = source.split(/\r?\n/);
11885
+ if (lines.length < 4) return source;
11886
+ const counts = /* @__PURE__ */ new Map();
11887
+ for (let index = 0; index < lines.length; index += 1) {
11888
+ const block = parseCommittedActivityPrefixBlock(lines, index);
11889
+ if (!block) continue;
11890
+ counts.set(block.label, (counts.get(block.label) || 0) + 1);
11891
+ index = block.nextIndex - 1;
11892
+ }
11893
+ const repeatedLabels = new Set(
11894
+ Array.from(counts.entries()).filter(([, count]) => count >= 3).map(([label]) => label)
11895
+ );
11896
+ if (repeatedLabels.size === 0) return source;
11897
+ const stripped = [];
11898
+ let removed = 0;
11899
+ for (let index = 0; index < lines.length; index += 1) {
11900
+ const block = parseCommittedActivityPrefixBlock(lines, index);
11901
+ if (block && repeatedLabels.has(block.label)) {
11902
+ removed += 1;
11903
+ index = block.nextIndex - 1;
11904
+ continue;
11905
+ }
11906
+ stripped.push(lines[index]);
11907
+ }
11908
+ const next = stripped.join("\n").replace(/\n{3,}/g, "\n\n").trim();
11909
+ return removed >= 3 && next.length >= 80 ? next : source;
11910
+ }
11911
+ function sanitizeCommittedMessageForDisplay(message) {
11912
+ if (!message || message.role !== "assistant" || (message.kind || "standard") !== "standard") return message;
11913
+ const content = sanitizeCliStandardMessageContent(message.content);
11914
+ if (content === message.content) return message;
11915
+ return { ...message, content };
11916
+ }
11917
+ var os12, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
11861
11918
  var init_provider_cli_adapter = __esm({
11862
11919
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
11863
11920
  "use strict";
@@ -11873,6 +11930,7 @@ var init_provider_cli_adapter = __esm({
11873
11930
  init_provider_cli_config();
11874
11931
  init_provider_cli_runtime();
11875
11932
  init_provider_cli_shared();
11933
+ COMMITTED_ACTIVITY_PREFIX_BLOCK_RE = /^(?:📖|💻|🔎|📚|📋|✏️|📝|🔧|🛠️|⚙️)\s+(.+)$/;
11876
11934
  ProviderCliAdapter = class _ProviderCliAdapter {
11877
11935
  constructor(provider, workingDir, extraArgs = [], transportFactory = new NodePtyTransportFactory()) {
11878
11936
  this.extraArgs = extraArgs;
@@ -12084,7 +12142,10 @@ var init_provider_cli_adapter = __esm({
12084
12142
  const tailFirst = parseBaseMessages[0];
12085
12143
  if (tailFirst && this.messagesComparable(parsedFirst, tailFirst)) {
12086
12144
  const prefixLength = fullBaseMessages.length - parseBaseMessages.length;
12087
- return [...fullBaseMessages.slice(0, prefixLength), ...parsedMessages];
12145
+ const prefix = fullBaseMessages.slice(0, prefixLength);
12146
+ const shouldSanitizePrefix = !!this.currentTurnScope || this.currentStatus !== "idle" || !!this.activeModal;
12147
+ const nextPrefix = shouldSanitizePrefix ? prefix.map((message) => sanitizeCommittedMessageForDisplay(message)) : prefix;
12148
+ return [...nextPrefix, ...parsedMessages];
12088
12149
  }
12089
12150
  return [...fullBaseMessages, ...parsedMessages];
12090
12151
  }
@@ -13283,10 +13344,12 @@ var init_provider_cli_adapter = __esm({
13283
13344
  }
13284
13345
  buildCommittedChatMessages() {
13285
13346
  return this.committedMessages.map((message, index) => {
13286
- const contentValue = message.content;
13347
+ const rawContentValue = message.content;
13348
+ const rawContent = typeof rawContentValue === "string" ? rawContentValue : String(rawContentValue || "");
13349
+ const content = message.role === "assistant" && (message.kind || "standard") === "standard" ? sanitizeCliStandardMessageContent(rawContent) : rawContent;
13287
13350
  return buildChatMessage({
13288
13351
  role: message.role,
13289
- content: typeof contentValue === "string" ? contentValue : String(contentValue || ""),
13352
+ content,
13290
13353
  timestamp: message.timestamp,
13291
13354
  kind: message.kind,
13292
13355
  meta: message.meta,
@@ -47513,8 +47576,12 @@ function sendToPeer(peer, data) {
47513
47576
  }
47514
47577
  return false;
47515
47578
  }
47579
+ const json2 = JSON.stringify(data);
47580
+ if (messageType === "command_result" && json2.length > MAX_INLINE_JSON_MESSAGE_CHARS) {
47581
+ return sendChunkedCommandResult(peer, peerId, requestId, json2);
47582
+ }
47516
47583
  try {
47517
- peer.dataChannel.sendMessage(JSON.stringify(data));
47584
+ peer.dataChannel.sendMessage(json2);
47518
47585
  return true;
47519
47586
  } catch (error48) {
47520
47587
  if (messageType === "command_result") {
@@ -47523,6 +47590,28 @@ function sendToPeer(peer, data) {
47523
47590
  return false;
47524
47591
  }
47525
47592
  }
47593
+ function sendChunkedCommandResult(peer, peerId, requestId, json2) {
47594
+ const chunkId = requestId || `command_result_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`;
47595
+ const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS);
47596
+ logDebug(`command_result chunked: peer=${peerId} id=${requestId || "-"} chars=${json2.length} chunks=${total}`);
47597
+ for (let index = 0; index < total; index += 1) {
47598
+ const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS);
47599
+ try {
47600
+ peer.dataChannel?.sendMessage(JSON.stringify({
47601
+ type: "command_result_chunk",
47602
+ id: requestId,
47603
+ chunkId,
47604
+ index,
47605
+ total,
47606
+ data: chunk
47607
+ }));
47608
+ } catch (error48) {
47609
+ log(`command_result send failed: peer=${peerId} id=${requestId || "-"} chunk=${index + 1}/${total} error=${error48?.message || error48}`);
47610
+ return false;
47611
+ }
47612
+ }
47613
+ return true;
47614
+ }
47526
47615
  function routeDataChannelMessage(peerId, msg, peers, handlers) {
47527
47616
  const text = typeof msg === "string" ? msg : msg.toString("utf-8");
47528
47617
  try {
@@ -47803,11 +47892,14 @@ async function handleFileRequest(peerId, req, peers, handlers) {
47803
47892
  }
47804
47893
  sendToPeer(peer, response);
47805
47894
  }
47895
+ var MAX_INLINE_JSON_MESSAGE_CHARS, JSON_CHUNK_PAYLOAD_CHARS;
47806
47896
  var init_data_channel_router = __esm({
47807
47897
  "src/daemon-p2p/data-channel-router.ts"() {
47808
47898
  "use strict";
47809
47899
  init_permission();
47810
47900
  init_log();
47901
+ MAX_INLINE_JSON_MESSAGE_CHARS = 6e4;
47902
+ JSON_CHUNK_PAYLOAD_CHARS = 32e3;
47811
47903
  }
47812
47904
  });
47813
47905
 
@@ -56690,7 +56782,7 @@ var init_adhdev_daemon = __esm({
56690
56782
  init_version();
56691
56783
  init_src();
56692
56784
  init_runtime_defaults();
56693
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.42" });
56785
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.44" });
56694
56786
  AdhdevDaemon = class _AdhdevDaemon {
56695
56787
  localHttpServer = null;
56696
56788
  localWss = null;