pi-readseek 0.5.2 → 0.5.4
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 +4 -4
- package/index.ts +2 -6
- package/package.json +1 -1
- package/src/readseek-settings.ts +25 -19
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ optional (defaults shown):
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
50
|
"readseek": {
|
|
51
|
-
"
|
|
51
|
+
"replacedTools": [],
|
|
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
|
-
- **
|
|
64
|
-
|
|
65
|
-
"grep"]`.
|
|
63
|
+
- **replacedTools:** 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
|
|
49
|
-
const knownTools = new Set([...pi.getAllTools().map((tool) => tool.name), ...READSEEK_TOOL_NAMES]);
|
|
48
|
+
const replacedTools = new Set<string>(settings.replacedTools ?? []);
|
|
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) => !
|
|
64
|
+
.filter((name) => !replacedTools.has(name));
|
|
69
65
|
pi.setActiveTools([...new Set(activeTools)]);
|
|
70
66
|
});
|
|
71
67
|
}
|
package/package.json
CHANGED
package/src/readseek-settings.ts
CHANGED
|
@@ -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
|
-
|
|
22
|
+
replacedTools?: 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 = ["
|
|
40
|
+
const READSEEK_KEYS = ["replacedTools", "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
|
|
115
|
+
function readReplacedTools(
|
|
108
116
|
raw: Record<string, unknown>,
|
|
109
|
-
key: string,
|
|
110
|
-
path: string,
|
|
111
117
|
source: string,
|
|
112
118
|
warnings: ReadSeekSettingsWarning[],
|
|
113
|
-
):
|
|
114
|
-
if (!(
|
|
115
|
-
const value = raw
|
|
119
|
+
): ReadSeekReplacementTool[] | undefined {
|
|
120
|
+
if (!("replacedTools" in raw)) return undefined;
|
|
121
|
+
const value = raw.replacedTools;
|
|
116
122
|
if (!Array.isArray(value)) {
|
|
117
|
-
warnings.push(invalid(source,
|
|
123
|
+
warnings.push(invalid(source, "readseek.replacedTools"));
|
|
118
124
|
return undefined;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
const
|
|
122
|
-
value.forEach((
|
|
123
|
-
if (typeof
|
|
124
|
-
|
|
125
|
-
|
|
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.replacedTools[${index}]`));
|
|
126
133
|
}
|
|
127
|
-
strings.push(item);
|
|
128
134
|
});
|
|
129
|
-
return
|
|
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
|
|
154
|
-
if (
|
|
159
|
+
const replacedTools = readReplacedTools(section, source, warnings);
|
|
160
|
+
if (replacedTools !== undefined) settings.replacedTools = replacedTools;
|
|
155
161
|
|
|
156
162
|
const imageMode = readImageMode(section, source, warnings);
|
|
157
163
|
if (imageMode !== undefined) settings.imageMode = imageMode;
|