@trim21/personal-pi-extensions 0.1.491 → 0.1.492

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.1.491",
3
+ "version": "0.1.492",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -18,10 +18,6 @@ import { Value } from "typebox/value";
18
18
  const fileSnapshotSchema = Type.Object({
19
19
  digest: Type.String(),
20
20
  textEditable: Type.Boolean(),
21
- // 以下字段仅 Read 写入,供同范围重复读取 dedup;Edit/Write 不写,
22
- // 覆盖记录后 offset 缺省 → 不再 dedup,强制重新 Read(对齐 CC readFileState)
23
- offset: Type.Optional(Type.Number()),
24
- limit: Type.Optional(Type.Number()),
25
21
  });
26
22
 
27
23
  export type FileSnapshot = Static<typeof fileSnapshotSchema>;
@@ -34,10 +34,6 @@ import { convertLeadingTabsToSpaces, findActualString, preserveQuoteStyle } from
34
34
 
35
35
  const SAMPLE_BYTES = 4096;
36
36
 
37
- /** 同范围重复读取、文件未变时返回的 stub(对齐 Claude Code 的 file_unchanged)。 */
38
- export const FILE_UNCHANGED_STUB =
39
- "File unchanged since last read. The content from the earlier Read tool_result in this conversation is still current — refer to that instead of re-reading.";
40
-
41
37
  /** Read 全读时的文件大小上限(对齐 Claude Code 的 256KB)。 */
42
38
  const MAX_READ_SIZE_BYTES = 0.25 * 1024 * 1024;
43
39
  /** Read 输出 token 粗估上限(对齐 Claude Code 的 25K tokens;无 tokenizer,按 4 字符/token 估算)。 */
@@ -317,21 +313,6 @@ export function registerFileTools(
317
313
  const key = await readStateKey(filePath);
318
314
  const buffer = await readFile(filePath);
319
315
 
320
- // 同范围 + checksum 未变 → 返回 stub 而非重发内容(对齐 CC readFileState;
321
- // 复用 reads 里的 sha256,比 mtime 可靠,无时间片粒度问题)
322
- const previous = state.reads.get(key);
323
- if (
324
- previous !== undefined &&
325
- previous.offset !== undefined &&
326
- previous.offset === offset &&
327
- previous.limit === limit &&
328
- snapshotsEqual(previous, snapshotOf(buffer))
329
- ) {
330
- return {
331
- content: [{ type: "text", text: FILE_UNCHANGED_STUB }],
332
- details: { pendant: { subtitle: formatSubtitlePath(ctx.cwd, filePath) } },
333
- };
334
- }
335
316
  if (isBinary(buffer.subarray(0, SAMPLE_BYTES)))
336
317
  throw new Error(`Cannot read binary file: ${filePath}`);
337
318
  // 全读(limit 未传)时受字节上限约束(对齐 Claude Code)
@@ -349,7 +330,7 @@ export function registerFileTools(
349
330
  `File content (${estimatedTokens} tokens) exceeds maximum allowed tokens (${MAX_READ_TOKENS}). Use offset and limit parameters to read specific portions of the file, or search for specific content instead of reading the whole file.`,
350
331
  );
351
332
  }
352
- const snapshot = { ...snapshotOf(buffer), offset, limit };
333
+ const snapshot = snapshotOf(buffer);
353
334
  state.reads.set(key, snapshot);
354
335
  // LSP 文件事件通知是后台任务,失败不影响读取(read 不驻留文档)
355
336
  void getService()