pi-readseek 0.5.2 → 0.5.3

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/README.md CHANGED
@@ -48,7 +48,7 @@ optional (defaults shown):
48
48
  ```json
49
49
  {
50
50
  "readseek": {
51
- "excludeTools": [],
51
+ "replaceTools": [],
52
52
  "imageMode": "force",
53
53
  "syntaxValidation": "warn",
54
54
  "timeoutMs": 120000,
@@ -60,9 +60,9 @@ optional (defaults shown):
60
60
  }
61
61
  ```
62
62
 
63
- - **excludeTools:** active tool names to hide after activating `readSeek_*`
64
- tools. For a readseek-only file surface, use `["read", "edit", "write",
65
- "grep"]`.
63
+ - **replaceTools:** built-in tool names to replace with their `readSeek_*` equivalents.
64
+ Valid values are `"read"`, `"edit"`, `"write"`, and `"grep"`. For a
65
+ readseek-only file surface, use `["read", "edit", "write", "grep"]`.
66
66
  - **imageMode:** image OCR/caption/object analysis in `readSeek_read`: `"force"`
67
67
  (or its alias `"on"`) always runs it, `"off"` returns only the image
68
68
  attachment, and `"auto"` runs it only when the active model does not support
package/index.ts CHANGED
@@ -45,12 +45,8 @@ export default function piReadSeekExtension(pi: ExtensionAPI): void {
45
45
 
46
46
  pi.on("session_start", (_event, ctx) => {
47
47
  const { settings, warnings } = resolveReadSeekJsonSettings();
48
- const excludeTools = new Set(settings.excludeTools ?? []);
49
- const knownTools = new Set([...pi.getAllTools().map((tool) => tool.name), ...READSEEK_TOOL_NAMES]);
48
+ const replaceTools = new Set<string>(settings.replaceTools ?? []);
50
49
  const problems = warnings.map(formatSettingsWarning);
51
- for (const name of excludeTools) {
52
- if (!knownTools.has(name)) problems.push(`Unknown tool "${name}" in readseek.excludeTools`);
53
- }
54
50
 
55
51
  const availability = readSeekBinaryAvailability();
56
52
  if (!availability.available) {
@@ -65,7 +61,7 @@ export default function piReadSeekExtension(pi: ExtensionAPI): void {
65
61
  if (!availability.available) return;
66
62
 
67
63
  const activeTools = [...pi.getActiveTools(), ...READSEEK_TOOL_NAMES]
68
- .filter((name) => !excludeTools.has(name));
64
+ .filter((name) => !replaceTools.has(name));
69
65
  pi.setActiveTools([...new Set(activeTools)]);
70
66
  });
71
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-readseek",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Pi extension for readseek-backed hash-anchored read/edit/grep, structural code maps, structural search, and file exploration",
5
5
  "type": "module",
6
6
  "exports": {
@@ -4,14 +4,22 @@ import { join } from "node:path";
4
4
 
5
5
  export type ReadSeekImageAnalysisMode = "force" | "off" | "auto";
6
6
  export type ReadSeekSyntaxValidationMode = "warn" | "block" | "off";
7
-
8
7
  interface ReadSeekGrepSettings {
9
8
  maxLines?: number;
10
9
  maxBytes?: number;
11
10
  }
12
11
 
12
+ const READSEEK_TOOL_REPLACEMENTS = {
13
+ read: "readSeek_read",
14
+ edit: "readSeek_edit",
15
+ grep: "readSeek_grep",
16
+ write: "readSeek_write",
17
+ } as const;
18
+
19
+ type ReadSeekReplacementTool = keyof typeof READSEEK_TOOL_REPLACEMENTS;
20
+
13
21
  interface ReadSeekJsonSettings {
14
- excludeTools?: string[];
22
+ replaceTools?: ReadSeekReplacementTool[];
15
23
  imageMode?: ReadSeekImageAnalysisMode;
16
24
  syntaxValidation?: ReadSeekSyntaxValidationMode;
17
25
  timeoutMs?: number;
@@ -29,7 +37,7 @@ export interface ReadSeekSettingsResult {
29
37
  warnings: ReadSeekSettingsWarning[];
30
38
  }
31
39
 
32
- const READSEEK_KEYS = ["excludeTools", "imageMode", "syntaxValidation", "timeoutMs", "grep"];
40
+ const READSEEK_KEYS = ["replaceTools", "imageMode", "syntaxValidation", "timeoutMs", "grep"];
33
41
  const READSEEK_GREP_KEYS = ["maxLines", "maxBytes"];
34
42
 
35
43
  function globalSettingsPath(): string {
@@ -104,29 +112,27 @@ function readImageMode(
104
112
  return undefined;
105
113
  }
106
114
 
107
- function readStringArray(
115
+ function readReplaceTools(
108
116
  raw: Record<string, unknown>,
109
- key: string,
110
- path: string,
111
117
  source: string,
112
118
  warnings: ReadSeekSettingsWarning[],
113
- ): string[] | undefined {
114
- if (!(key in raw)) return undefined;
115
- const value = raw[key];
119
+ ): ReadSeekReplacementTool[] | undefined {
120
+ if (!("replaceTools" in raw)) return undefined;
121
+ const value = raw.replaceTools;
116
122
  if (!Array.isArray(value)) {
117
- warnings.push(invalid(source, path));
123
+ warnings.push(invalid(source, "readseek.replaceTools"));
118
124
  return undefined;
119
125
  }
120
126
 
121
- const strings: string[] = [];
122
- value.forEach((item, index) => {
123
- if (typeof item !== "string" || item.trim() === "") {
124
- warnings.push(invalid(source, `${path}[${index}]`));
125
- return;
127
+ const tools: ReadSeekReplacementTool[] = [];
128
+ value.forEach((tool, index) => {
129
+ if (typeof tool === "string" && Object.hasOwn(READSEEK_TOOL_REPLACEMENTS, tool)) {
130
+ tools.push(tool as ReadSeekReplacementTool);
131
+ } else {
132
+ warnings.push(invalid(source, `readseek.replaceTools[${index}]`));
126
133
  }
127
- strings.push(item);
128
134
  });
129
- return strings;
135
+ return tools;
130
136
  }
131
137
 
132
138
  function validateSettings(raw: unknown, source: string): ReadSeekSettingsResult {
@@ -150,8 +156,8 @@ function validateSettings(raw: unknown, source: string): ReadSeekSettingsResult
150
156
  const section = raw.readseek;
151
157
  warnUnknownKeys(section, READSEEK_KEYS, "readseek", source, warnings);
152
158
 
153
- const excludeTools = readStringArray(section, "excludeTools", "readseek.excludeTools", source, warnings);
154
- if (excludeTools !== undefined) settings.excludeTools = excludeTools;
159
+ const replaceTools = readReplaceTools(section, source, warnings);
160
+ if (replaceTools !== undefined) settings.replaceTools = replaceTools;
155
161
 
156
162
  const imageMode = readImageMode(section, source, warnings);
157
163
  if (imageMode !== undefined) settings.imageMode = imageMode;