pi-read-chunks 1.0.4 → 1.0.6

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/package.json +1 -1
  2. package/read-chunks.ts +16 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-read-chunks",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A Pi Agent extension that uses a subagent to enhance `read` functionality for large text files to reduce context bloat, rot and lost in the middle issues.",
5
5
  "keywords": [
6
6
  "pi-package",
package/read-chunks.ts CHANGED
@@ -268,9 +268,14 @@ function buildSummarisePrompt(
268
268
  hasPriorSummary
269
269
  ? "Include any relevant context from the prior summary below, but the summary should be focused on the new chunk. Do NOT repeat or echo the prior summary. Write a fresh summary of the CURRENT chunk."
270
270
  : `Write a fresh summary of the CURRENT chunk. Be concise and factual. ${FACT_GUARD}`,
271
- 'If this chunk contains information that answers the query, begin your reply with exactly "| ANSWER:" ' +
271
+ 'If this chunk contains information that FULLY answers the query, begin your reply with exactly "| ANSWER:" ' +
272
272
  'followed by the precise answer passage, then a newline, then "---", then your NEW summary of this chunk.',
273
273
  "Otherwise reply with ONLY your NEW summary of this chunk (no marker, no separator).",
274
+
275
+ "CRITICAL: Only emit the \"| ANSWER:\" marker if the chunk alone provides the COMPLETE answer to the query.",
276
+ "If the query requires information from multiple parts of the file (e.g., a synopsis, comparison, timeline),",
277
+ "do NOT mark individual chunks as answers. Continue reading until either the complete answer is found",
278
+ "or the file has been fully read.",
274
279
  FACT_GUARD,
275
280
  );
276
281
  parts.push("", `Query: "${query}`);
@@ -683,7 +688,7 @@ export default function (pi: ExtensionAPI) {
683
688
 
684
689
  return {
685
690
  block: true,
686
- reason: "Built-in read() is disabled for text files. Use read-chunks(path/file, query) with a concise query describing what you are looking for.",
691
+ reason: "For text files: use read-chunks(path/file) or read-chunks(path/file, query) with a concise query describing what you are looking for or read-chunks(path/file):linestart-lineend for a bounded file read.",
687
692
  };
688
693
  });
689
694
 
@@ -748,6 +753,15 @@ function formatReadChunksCall(args: any, theme: any, cwd: string): string {
748
753
  if (m && m.index !== undefined) {
749
754
  rangeSuffix = `:${m[2]}${m[3] !== undefined ? `-${m[3]}` : ""}`;
750
755
  pathPart = m[1];
756
+ } else {
757
+ // No `:suffix` on path: derive the same `:START[-END]` form from explicit
758
+ // offset/limit args so the header reflects what was actually requested.
759
+ // Matches execute()'s semantics: offset alone = start at line N, read to EOF.
760
+ const off = typeof args?.offset === "number" ? args.offset : undefined;
761
+ const lim = typeof args?.limit === "number" ? args.limit : undefined;
762
+ if (off !== undefined) {
763
+ rangeSuffix = lim !== undefined ? `:${off}-${off + lim - 1}` : `:${off}`;
764
+ }
751
765
  }
752
766
 
753
767
  const pathDisplay = renderToolPath(pathPart || null, theme, cwd);