pi-readseek 0.5.1 → 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 +4 -4
- package/index.ts +2 -6
- package/package.json +1 -1
- package/src/hover.ts +2 -2
- package/src/readseek-settings.ts +25 -19
- package/src/rename.ts +2 -2
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ optional (defaults shown):
|
|
|
48
48
|
```json
|
|
49
49
|
{
|
|
50
50
|
"readseek": {
|
|
51
|
-
"
|
|
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
|
-
- **
|
|
64
|
-
|
|
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
|
|
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) => !
|
|
64
|
+
.filter((name) => !replaceTools.has(name));
|
|
69
65
|
pi.setActiveTools([...new Set(activeTools)]);
|
|
70
66
|
});
|
|
71
67
|
}
|
package/package.json
CHANGED
package/src/hover.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { formatFsError } from "./fs-error.js";
|
|
|
11
11
|
import { classifyReadSeekFailure, readSeekIdentify } from "./readseek-client.js";
|
|
12
12
|
import { filePathParam, registerReadSeekTool } from "./register-tool.js";
|
|
13
13
|
|
|
14
|
-
import { clampLinesToWidth, linkToolPath, renderPendingResult, resolveRenderResultContext, summaryLine } from "./tui-render-utils.js";
|
|
14
|
+
import { clampLineToWidth, clampLinesToWidth, linkToolPath, renderPendingResult, resolveRenderResultContext, summaryLine } from "./tui-render-utils.js";
|
|
15
15
|
|
|
16
16
|
const HOVER_PROMPT_METADATA = defineToolPromptMetadata({
|
|
17
17
|
promptUrl: new URL("../prompts/hover.md", import.meta.url),
|
|
@@ -109,7 +109,7 @@ export function registerHoverTool(pi: ExtensionAPI) {
|
|
|
109
109
|
let text = theme.fg("toolTitle", theme.bold("hover"));
|
|
110
110
|
text += ` ${linkToolPath(theme.fg("accent", displayPath), displayPath, cwd)}`;
|
|
111
111
|
if (args?.line) text += theme.fg("dim", `:${args.line}`);
|
|
112
|
-
return text;
|
|
112
|
+
return new Text(clampLineToWidth(text, context.width), 0, 0);
|
|
113
113
|
},
|
|
114
114
|
renderResult(result: any, options: ToolRenderResultOptions, theme: any, ...rest: any[]) {
|
|
115
115
|
const { isPartial, isError, width } = resolveRenderResultContext(options, rest);
|
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
|
+
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 = ["
|
|
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
|
|
115
|
+
function readReplaceTools(
|
|
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 (!("replaceTools" in raw)) return undefined;
|
|
121
|
+
const value = raw.replaceTools;
|
|
116
122
|
if (!Array.isArray(value)) {
|
|
117
|
-
warnings.push(invalid(source,
|
|
123
|
+
warnings.push(invalid(source, "readseek.replaceTools"));
|
|
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.replaceTools[${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 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;
|
package/src/rename.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { resolveToCwd } from "./path-utils.js";
|
|
|
9
9
|
import { classifyReadSeekFailure, readSeekRename, type RenameOutput } from "./readseek-client.js";
|
|
10
10
|
import { filePathParam, registerReadSeekTool } from "./register-tool.js";
|
|
11
11
|
|
|
12
|
-
import { clampLinesToWidth, linkToolPath, renderPendingResult, resolveRenderResultContext, summaryLine } from "./tui-render-utils.js";
|
|
12
|
+
import { clampLineToWidth, clampLinesToWidth, linkToolPath, renderPendingResult, resolveRenderResultContext, summaryLine } from "./tui-render-utils.js";
|
|
13
13
|
|
|
14
14
|
const RENAME_PROMPT_METADATA = defineToolPromptMetadata({
|
|
15
15
|
promptUrl: new URL("../prompts/rename.md", import.meta.url),
|
|
@@ -125,7 +125,7 @@ export function registerRenameTool(pi: ExtensionAPI) {
|
|
|
125
125
|
let text = theme.fg("toolTitle", theme.bold("rename"));
|
|
126
126
|
text += ` ${linkToolPath(theme.fg("accent", displayPath), displayPath, cwd)}`;
|
|
127
127
|
if (args?.to) text += theme.fg("dim", ` → ${args.to}`);
|
|
128
|
-
return text;
|
|
128
|
+
return new Text(clampLineToWidth(text, context.width), 0, 0);
|
|
129
129
|
},
|
|
130
130
|
renderResult(result: any, options: ToolRenderResultOptions, theme: any, ...rest: any[]) {
|
|
131
131
|
const { isPartial, isError, expanded, width } = resolveRenderResultContext(options, rest);
|