opencode-acp 1.14.16-pr.302.8 → 1.14.16-pr.302.9

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
@@ -2075,7 +2075,7 @@ THE FORMAT OF COMPRESS
2075
2075
  ]
2076
2076
  }
2077
2077
  \`\`\`
2078
- Each entry needs a topic \u2014 either its own or the top-level fallback.`;
2078
+ Each entry MAY have a topic. Missing topics fall back to the top-level topic, then to an automatic one derived from the summary.`;
2079
2079
 
2080
2080
  // lib/state/persistence.ts
2081
2081
  import * as fs from "fs/promises";
@@ -3756,8 +3756,11 @@ function filterProtectedRecentMessages(selection, searchContext, state, compress
3756
3756
 
3757
3757
  // lib/compress/range-utils.ts
3758
3758
  var BLOCK_PLACEHOLDER_REGEX = /\(b(\d+)\)|\{block_(\d+)\}/gi;
3759
+ function deriveFallbackTopic(summary) {
3760
+ const firstLine = summary.split("\n").map((line) => line.replace(/^#{1,6}\s*/, "").trim()).find((line) => line.length > 0) ?? "compressed range";
3761
+ return firstLine.length > 80 ? `${firstLine.slice(0, 77)}...` : firstLine;
3762
+ }
3759
3763
  function validateArgs(args) {
3760
- const hasTopLevelTopic = typeof args.topic === "string" && args.topic.trim().length > 0;
3761
3764
  if (!Array.isArray(args.content) || args.content.length === 0) {
3762
3765
  throw new Error("content is required and must be a non-empty array");
3763
3766
  }
@@ -3773,18 +3776,12 @@ function validateArgs(args) {
3773
3776
  if (typeof entry?.summary !== "string" || entry.summary.trim().length === 0) {
3774
3777
  throw new Error(`${prefix}.summary is required and must be a non-empty string`);
3775
3778
  }
3776
- const hasEntryTopic = typeof entry?.topic === "string" && entry.topic.trim().length > 0;
3777
- if (!hasEntryTopic && !hasTopLevelTopic) {
3778
- throw new Error(
3779
- `${prefix} needs a topic \u2014 provide ${prefix}.topic or the top-level topic`
3780
- );
3781
- }
3782
3779
  }
3783
3780
  }
3784
3781
  function resolveRanges(args, searchContext, state, logger) {
3785
3782
  return args.content.map((entry, index) => {
3786
3783
  const normalizedEntry = {
3787
- topic: typeof entry.topic === "string" && entry.topic.trim().length > 0 ? entry.topic.trim() : void 0,
3784
+ topic: typeof entry.topic === "string" && entry.topic.trim().length > 0 ? entry.topic.trim() : typeof args.topic === "string" && args.topic.trim().length > 0 ? void 0 : deriveFallbackTopic(entry.summary),
3788
3785
  startId: entry.startId.trim(),
3789
3786
  endId: entry.endId.trim(),
3790
3787
  summary: entry.summary
@@ -8947,7 +8944,7 @@ import { writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
8947
8944
  import { join as join3 } from "path";
8948
8945
  import { existsSync as existsSync3 } from "fs";
8949
8946
  import { homedir as homedir3 } from "os";
8950
- var LOG_VERSION = true ? "1.14.16-pr.302.8" : "dev";
8947
+ var LOG_VERSION = true ? "1.14.16-pr.302.9" : "dev";
8951
8948
  var Logger = class {
8952
8949
  logDir;
8953
8950
  enabled;
@@ -9275,7 +9272,7 @@ Rules:
9275
9272
  BATCHING
9276
9273
  When multiple independent ranges are ready and their boundaries do not overlap, include all of them as separate entries in the \`content\` array of a single tool call. Each entry should have its own \`startId\`, \`endId\`, and \`summary\`.
9277
9274
 
9278
- When the ranges cover unrelated topics, give each entry its own \`topic\` for better summary quality \u2014 do not force unrelated content under a single shared topic. Omit the top-level \`topic\` when every entry has its own. Use the top-level \`topic\` only as a fallback when entries don't specify one.
9275
+ When the ranges cover unrelated topics, give each entry its own \`topic\` for better summary quality \u2014 do not force unrelated content under a single shared topic. The top-level \`topic\` is an optional fallback; when no topic is provided at all, one is derived from the summary's first line automatically.
9279
9276
 
9280
9277
  \`\`\`
9281
9278
  compress({ content: [