pi-readseek 0.6.3 → 0.6.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/package.json +2 -2
- package/prompts/def.md +2 -6
- package/prompts/edit.md +3 -3
- package/prompts/grep.md +1 -7
- package/prompts/hover.md +1 -6
- package/prompts/read.md +3 -1
- package/prompts/refs.md +1 -4
- package/prompts/rename.md +1 -11
- package/prompts/sg.md +1 -5
- package/prompts/write.md +1 -4
- package/src/def.ts +1 -1
- package/src/edit.ts +4 -2
- package/src/grep.ts +7 -7
- package/src/hover.ts +1 -1
- package/src/read.ts +3 -3
- package/src/readseek-params.ts +2 -2
- package/src/refs.ts +4 -4
- package/src/register-tool.ts +1 -1
- package/src/rename.ts +6 -6
- package/src/sg.ts +2 -2
- package/src/tool-prompt-metadata.ts +3 -16
- package/src/write.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-readseek",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
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": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"node": ">=20.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@jarkkojs/readseek": "^0.6.
|
|
42
|
+
"@jarkkojs/readseek": "^0.6.4",
|
|
43
43
|
"diff": "^8.0.3",
|
|
44
44
|
"xxhash-wasm": "^1.1.0"
|
|
45
45
|
},
|
package/prompts/def.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Find
|
|
2
|
-
directory.
|
|
1
|
+
Find symbol declarations by qualified or unqualified name. Use instead of text search when locating where a function, class, type, or other symbol is defined.
|
|
3
2
|
|
|
4
3
|
## Parameters
|
|
5
4
|
|
|
@@ -8,7 +7,4 @@ directory.
|
|
|
8
7
|
- `lang` — language override.
|
|
9
8
|
- `cached`, `others`, `ignored` — Git file selection; `ignored` requires `others`.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- After `readSeek_hover`, use its qualified symbol name.
|
|
14
|
-
- When asked where a function, class, or type is defined.
|
|
10
|
+
After `readSeek_hover`, use its qualified symbol name.
|
package/prompts/edit.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Edit existing text files with fresh `LINE:HASH` anchors
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
Edit existing text files safely with fresh `LINE:HASH` anchors; on `file-not-read`, read or search the file first.
|
|
2
|
+
|
|
3
|
+
Anchors come from `readSeek_read`, `readSeek_grep`, `readSeek_search`, or `readSeek_write`.
|
|
4
4
|
|
|
5
5
|
## Variants
|
|
6
6
|
|
package/prompts/grep.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Search
|
|
1
|
+
Search plain text or regex in files and return edit-ready `LINE:HASH` anchors. Use for identifiers, strings, configuration, errors, comments, or documentation.
|
|
2
2
|
|
|
3
3
|
## Modes
|
|
4
4
|
|
|
@@ -19,10 +19,4 @@ Search file contents. Non-summary results include edit-ready `LINE:HASH` anchors
|
|
|
19
19
|
- `scope` — only `"symbol"` is supported.
|
|
20
20
|
- `scopeContext` — non-negative context within symbol scope; requires `scope: "symbol"`.
|
|
21
21
|
|
|
22
|
-
## Use well
|
|
23
|
-
|
|
24
|
-
Use `readSeek_grep` for text: identifiers, strings, config keys, error messages, comments, or docs. Use `literal: true` unless you want regex behavior.
|
|
25
|
-
|
|
26
|
-
For code shape — calls, imports, declarations, JSX, object literals, control flow — prefer `readSeek_search`, which parses AST patterns.
|
|
27
|
-
|
|
28
22
|
If output says results were truncated at `limit` or by display budget, narrow before editing. Good narrowing order: `summary` → `path`/`glob` → stricter pattern → `scope: "symbol"` or `context`.
|
package/prompts/hover.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
Identify the
|
|
2
|
-
is included.
|
|
1
|
+
Identify the token and enclosing symbol at a cursor. Use before rename or definition lookup, or to identify a line's enclosing symbol; unsaved editor content is included.
|
|
3
2
|
|
|
4
3
|
## Parameters
|
|
5
4
|
|
|
6
5
|
- `path`, `line` — required file path and one-based cursor line.
|
|
7
6
|
- `column` — optional one-based cursor byte column.
|
|
8
|
-
|
|
9
|
-
## When to use
|
|
10
|
-
|
|
11
|
-
- Before rename or go-to-definition, or to identify a line's enclosing symbol.
|
package/prompts/read.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Read
|
|
1
|
+
Read anchored text by range, map, or symbol, and process images or PDFs with an explicit mode.
|
|
2
2
|
|
|
3
3
|
## Choose the right read
|
|
4
4
|
|
|
@@ -16,6 +16,8 @@ Read files through readseek. Text results use `LINE:HASH|content` anchors for `r
|
|
|
16
16
|
- `bundle` — only `"local"`; requires `symbol` and excludes `map`.
|
|
17
17
|
- `image` — an exposed image/PDF mode.
|
|
18
18
|
|
|
19
|
+
Default cap: {{DEFAULT_MAX_LINES}} lines or {{DEFAULT_MAX_BYTES}}. Omitting `image` skips images and PDFs.
|
|
20
|
+
|
|
19
21
|
Truncated full-file reads append a map when available. Use its ranges for follow-up reads.
|
|
20
22
|
|
|
21
23
|
## Symbol examples
|
package/prompts/refs.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Find identifier
|
|
2
|
-
text search is too broad. Results include edit-ready anchors and enclosing symbols.
|
|
1
|
+
Find identifier usages with enclosing symbols and edit-ready anchors. Use before renaming, deleting, or changing a symbol; add a cursor scope to exclude same-named bindings.
|
|
3
2
|
|
|
4
3
|
## Parameters
|
|
5
4
|
|
|
@@ -23,5 +22,3 @@ shadows.
|
|
|
23
22
|
|
|
24
23
|
In Git repositories, directory search includes tracked/indexed and untracked
|
|
25
24
|
non-ignored files. `ignored` requires `others`.
|
|
26
|
-
|
|
27
|
-
Use `readSeek_grep` for plain text, `readSeek_search` for code shape, and `readSeek_refs` for identifier usage.
|
package/prompts/rename.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
Rename
|
|
2
|
-
only occurrences of that declaration are changed.
|
|
1
|
+
Rename the symbol at a cursor without changing same-named bindings. Use for symbol renames; use search and edit for broader refactors.
|
|
3
2
|
|
|
4
3
|
## Parameters
|
|
5
4
|
|
|
@@ -7,12 +6,3 @@ only occurrences of that declaration are changed.
|
|
|
7
6
|
- `column` — optional one-based cursor byte column.
|
|
8
7
|
- `workspace` — expand across the project; local shadows in other files are excluded.
|
|
9
8
|
- `apply` — default `true`; set `false` to return only the verified plan.
|
|
10
|
-
|
|
11
|
-
## When to use
|
|
12
|
-
|
|
13
|
-
- Use when the user requests a symbol rename and the cursor is known.
|
|
14
|
-
|
|
15
|
-
## When not to use
|
|
16
|
-
|
|
17
|
-
- Use `readSeek_grep`/`readSeek_search` for broad replacement and
|
|
18
|
-
`readSeek_edit` for other refactors.
|
package/prompts/sg.md
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
Search code with AST patterns
|
|
2
|
-
imports, declarations, JSX, object fields, and control flow. Results include
|
|
3
|
-
edit-ready anchors.
|
|
1
|
+
Search syntax-aware code shapes with AST patterns and return edit-ready anchors. Use for calls, imports, declarations, JSX, object fields, or control flow; use `readSeek_grep` for plain text.
|
|
4
2
|
|
|
5
3
|
## Parameters
|
|
6
4
|
|
|
@@ -35,5 +33,3 @@ punctuation must be valid for the selected language.
|
|
|
35
33
|
In Git repositories, directory search includes tracked/indexed and untracked
|
|
36
34
|
non-ignored files. Use `cached`, `others`, and `ignored` to choose; `ignored`
|
|
37
35
|
requires `others`.
|
|
38
|
-
|
|
39
|
-
Use `readSeek_grep` for plain text and `readSeek_search` for structure.
|
package/prompts/write.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
Create or replace a
|
|
1
|
+
Create or replace a complete file and return `LINE:HASH` anchors. Use for new or fully generated files; use anchored edits for small changes.
|
|
2
2
|
|
|
3
3
|
## Use / avoid
|
|
4
4
|
|
|
5
|
-
Use it for new, generated, or intentionally replaced files. For small changes or
|
|
6
|
-
appends, read/search first and use `readSeek_edit`.
|
|
7
|
-
|
|
8
5
|
Existing files are overwritten without confirmation. Binary-looking content gets
|
|
9
6
|
no anchors.
|
|
10
7
|
|
package/src/def.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type { FileAnchoredCallback } from "./tool-types.js";
|
|
|
15
15
|
|
|
16
16
|
const DEF_PROMPT_METADATA = defineToolPromptMetadata({
|
|
17
17
|
promptUrl: new URL("../prompts/def.md", import.meta.url),
|
|
18
|
-
promptSnippet: "Find
|
|
18
|
+
promptSnippet: "Find where a symbol is defined",
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
type DefParams = {
|
package/src/edit.ts
CHANGED
|
@@ -59,7 +59,9 @@ const hashlineEditItemSchema = Type.Union([
|
|
|
59
59
|
const hashlineEditSchema = Type.Object(
|
|
60
60
|
{
|
|
61
61
|
path: filePathParam(),
|
|
62
|
-
edits: Type.Optional(Type.Array(hashlineEditItemSchema, {
|
|
62
|
+
edits: Type.Optional(Type.Array(hashlineEditItemSchema, {
|
|
63
|
+
description: "Edits: set_line, replace_lines, insert_after, replace_symbol, or replace",
|
|
64
|
+
})),
|
|
63
65
|
postEditVerify: Type.Optional(Type.Boolean({
|
|
64
66
|
description: "Verify persisted content after write",
|
|
65
67
|
})),
|
|
@@ -565,7 +567,7 @@ export function registerEditTool(pi: ExtensionAPI, options: EditToolOptions = {}
|
|
|
565
567
|
const name = options.name ?? "readSeek_edit";
|
|
566
568
|
const promptMetadata = defineToolPromptMetadata({
|
|
567
569
|
promptUrl: new URL("../prompts/edit.md", import.meta.url),
|
|
568
|
-
promptSnippet: "
|
|
570
|
+
promptSnippet: "Safely edit with fresh LINE:HASH anchors",
|
|
569
571
|
registeredName: name,
|
|
570
572
|
toolAliases: options.toolAliases,
|
|
571
573
|
});
|
package/src/grep.ts
CHANGED
|
@@ -26,20 +26,20 @@ import { searchPathParam } from "./readseek-params.js";
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
const grepSchema = Type.Object({
|
|
29
|
-
pattern: Type.String({ description: "
|
|
29
|
+
pattern: Type.String({ description: "Regex pattern; use literal for exact text" }),
|
|
30
30
|
path: searchPathParam(),
|
|
31
|
-
glob: Type.Optional(Type.String({ description: "
|
|
31
|
+
glob: Type.Optional(Type.String({ description: "File-name glob, such as *.ts" })),
|
|
32
32
|
ignoreCase: Type.Optional(Type.Boolean({ description: "Ignore case" })),
|
|
33
33
|
literal: Type.Optional(Type.Boolean({ description: "Treat pattern literally" })),
|
|
34
|
-
context: optionalIntOrString("
|
|
35
|
-
limit: optionalIntOrString("
|
|
34
|
+
context: optionalIntOrString("Surrounding lines for each match"),
|
|
35
|
+
limit: optionalIntOrString("Maximum matches to return"),
|
|
36
36
|
summary: Type.Optional(Type.Boolean({ description: "Return per-file counts" })),
|
|
37
37
|
scope: Type.Optional(
|
|
38
38
|
Type.Literal("symbol", {
|
|
39
|
-
description: "
|
|
39
|
+
description: "Group matches by enclosing symbol",
|
|
40
40
|
}),
|
|
41
41
|
),
|
|
42
|
-
scopeContext: optionalIntOrString("
|
|
42
|
+
scopeContext: optionalIntOrString("Context lines within each symbol"),
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
interface GrepParams {
|
|
@@ -513,7 +513,7 @@ export function registerGrepTool(pi: ExtensionAPI, options: GrepToolOptions = {}
|
|
|
513
513
|
const name = options.name ?? "readSeek_grep";
|
|
514
514
|
const promptMetadata = defineToolPromptMetadata({
|
|
515
515
|
promptUrl: new URL("../prompts/grep.md", import.meta.url),
|
|
516
|
-
promptSnippet: "Search
|
|
516
|
+
promptSnippet: "Search plain text or regex with edit-ready anchors",
|
|
517
517
|
registeredName: name,
|
|
518
518
|
});
|
|
519
519
|
const tool = registerReadSeekTool(pi, {
|
package/src/hover.ts
CHANGED
|
@@ -15,7 +15,7 @@ import { clampLineToWidth, clampLinesToWidth, linkToolPath, renderErrorResult, r
|
|
|
15
15
|
|
|
16
16
|
const HOVER_PROMPT_METADATA = defineToolPromptMetadata({
|
|
17
17
|
promptUrl: new URL("../prompts/hover.md", import.meta.url),
|
|
18
|
-
promptSnippet: "Identify
|
|
18
|
+
promptSnippet: "Identify the token and enclosing symbol at a cursor",
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const hoverSchema = Type.Object({
|
package/src/read.ts
CHANGED
|
@@ -524,7 +524,7 @@ export function registerReadTool(pi: ExtensionAPI, options: ReadToolOptions = {}
|
|
|
524
524
|
const imageModes = imageMode === "auto" ? ["none", "ocr", "caption", "objects"] as const : ["ocr", "caption", "objects"] as const;
|
|
525
525
|
const promptMetadata = defineToolPromptMetadata({
|
|
526
526
|
promptUrl: new URL("../prompts/read.md", import.meta.url),
|
|
527
|
-
promptSnippet: "Read
|
|
527
|
+
promptSnippet: "Read anchored text, symbols, maps, images, or PDFs",
|
|
528
528
|
registeredName: name,
|
|
529
529
|
});
|
|
530
530
|
const tool = registerReadSeekTool(pi, {
|
|
@@ -541,12 +541,12 @@ export function registerReadTool(pi: ExtensionAPI, options: ReadToolOptions = {}
|
|
|
541
541
|
parameters: Type.Object({
|
|
542
542
|
path: filePathParam(),
|
|
543
543
|
offset: optionalIntOrString("Start line (1-indexed)"),
|
|
544
|
-
limit: optionalIntOrString("
|
|
544
|
+
limit: optionalIntOrString("Maximum lines to return"),
|
|
545
545
|
symbol: Type.Optional(Type.String({ description: "Symbol name to read" })),
|
|
546
546
|
map: mapParam(),
|
|
547
547
|
bundle: Type.Optional(
|
|
548
548
|
Type.Literal("local", {
|
|
549
|
-
description: "Include same
|
|
549
|
+
description: "Include related symbols from the same file; requires symbol",
|
|
550
550
|
}),
|
|
551
551
|
),
|
|
552
552
|
...(imageMode === "off"
|
package/src/readseek-params.ts
CHANGED
|
@@ -4,12 +4,12 @@ import { buildToolErrorResult, type ToolErrorResult } from "./readseek-value.js"
|
|
|
4
4
|
|
|
5
5
|
/** Optional search path shared by the readseek search tools. */
|
|
6
6
|
export function searchPathParam() {
|
|
7
|
-
return Type.Optional(Type.String({ description: "
|
|
7
|
+
return Type.Optional(Type.String({ description: "File or directory to search" }));
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/** Optional language hint shared by the readseek search tools. */
|
|
11
11
|
export function langParam() {
|
|
12
|
-
return Type.Optional(Type.String({ description: "Language
|
|
12
|
+
return Type.Optional(Type.String({ description: "Language override when auto-detection is ambiguous" }));
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
package/src/refs.ts
CHANGED
|
@@ -27,7 +27,7 @@ type RefsParams = {
|
|
|
27
27
|
|
|
28
28
|
const REFS_PROMPT_METADATA = defineToolPromptMetadata({
|
|
29
29
|
promptUrl: new URL("../prompts/refs.md", import.meta.url),
|
|
30
|
-
promptSnippet: "Find identifier
|
|
30
|
+
promptSnippet: "Find usages of an identifier or cursor binding",
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
interface RefsToolOptions {
|
|
@@ -133,9 +133,9 @@ export function registerRefsTool(pi: ExtensionAPI, options: RefsToolOptions = {}
|
|
|
133
133
|
name: Type.String({ description: "Identifier to find references for" }),
|
|
134
134
|
path: searchPathParam(),
|
|
135
135
|
lang: langParam(),
|
|
136
|
-
scope: Type.Optional(Type.Boolean({ description: "Restrict to the binding
|
|
137
|
-
line: Type.Optional(Type.Number({ description: "
|
|
138
|
-
column: Type.Optional(Type.Number({ description: "
|
|
136
|
+
scope: Type.Optional(Type.Boolean({ description: "Restrict results to the binding at the cursor" })),
|
|
137
|
+
line: Type.Optional(Type.Number({ description: "Cursor line (1-indexed), required with scope" })),
|
|
138
|
+
column: Type.Optional(Type.Number({ description: "Cursor byte column (1-indexed) for disambiguation" })),
|
|
139
139
|
...readSeekGitSearchParams(),
|
|
140
140
|
}),
|
|
141
141
|
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
|
package/src/register-tool.ts
CHANGED
|
@@ -12,7 +12,7 @@ export function optionalIntOrString(description: string) {
|
|
|
12
12
|
|
|
13
13
|
/** Required file-path parameter shared by the read, edit, and write tools. */
|
|
14
14
|
export function filePathParam() {
|
|
15
|
-
return Type.String({ description: "
|
|
15
|
+
return Type.String({ description: "Absolute or relative file path" });
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/** Optional structural-map toggle shared by the read and write tools. */
|
package/src/rename.ts
CHANGED
|
@@ -13,16 +13,16 @@ import { clampLineToWidth, clampLinesToWidth, linkedPathLine, linkToolPath, rend
|
|
|
13
13
|
|
|
14
14
|
const RENAME_PROMPT_METADATA = defineToolPromptMetadata({
|
|
15
15
|
promptUrl: new URL("../prompts/rename.md", import.meta.url),
|
|
16
|
-
promptSnippet: "Rename a
|
|
16
|
+
promptSnippet: "Rename the symbol at a cursor without touching shadows",
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const renameSchema = Type.Object({
|
|
20
20
|
path: filePathParam(),
|
|
21
|
-
line: Type.Number({ description: "One-based
|
|
22
|
-
column: Type.Optional(Type.Number({ description: "One-based
|
|
23
|
-
to: Type.String({ description: "New name
|
|
24
|
-
workspace: Type.Optional(Type.Boolean({ description: "
|
|
25
|
-
apply: Type.Optional(Type.Boolean({ description: "
|
|
21
|
+
line: Type.Number({ description: "One-based line of the symbol to rename" }),
|
|
22
|
+
column: Type.Optional(Type.Number({ description: "One-based byte column for disambiguation" })),
|
|
23
|
+
to: Type.String({ description: "New symbol name" }),
|
|
24
|
+
workspace: Type.Optional(Type.Boolean({ description: "Rename across the project" })),
|
|
25
|
+
apply: Type.Optional(Type.Boolean({ description: "Apply the verified edits; default true" })),
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
interface RenameParams {
|
package/src/sg.ts
CHANGED
|
@@ -49,7 +49,7 @@ export function mergeRanges(ranges: SgRange[]): SgRange[] {
|
|
|
49
49
|
|
|
50
50
|
const SG_PROMPT_METADATA = defineToolPromptMetadata({
|
|
51
51
|
promptUrl: new URL("../prompts/sg.md", import.meta.url),
|
|
52
|
-
promptSnippet: "Search code
|
|
52
|
+
promptSnippet: "Search syntax-aware code shapes with AST patterns",
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
interface SgToolOptions {
|
|
@@ -190,7 +190,7 @@ export function registerSgTool(pi: ExtensionAPI, options: SgToolOptions = {}) {
|
|
|
190
190
|
promptSnippet: SG_PROMPT_METADATA.promptSnippet,
|
|
191
191
|
promptGuidelines: SG_PROMPT_METADATA.promptGuidelines,
|
|
192
192
|
parameters: Type.Object({
|
|
193
|
-
pattern: Type.String({ description: "
|
|
193
|
+
pattern: Type.String({ description: "ast-grep pattern, such as console.log($$$ARGS)" }),
|
|
194
194
|
lang: langParam(),
|
|
195
195
|
path: searchPathParam(),
|
|
196
196
|
...readSeekGitSearchParams(),
|
|
@@ -2,16 +2,6 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
|
|
5
|
-
const COMPACT_DESCRIPTIONS: Record<string, string> = {
|
|
6
|
-
"read.md": "Read text files, images, or PDFs by path; text has LINE:HASH anchors and visual files require an explicit image mode.",
|
|
7
|
-
"edit.md": "Edit existing text files using fresh LINE:HASH anchors from readSeek_read, readSeek_grep, readSeek_search, or readSeek_write.",
|
|
8
|
-
"grep.md": "Search file contents; non-summary results include LINE:HASH anchors for edits.",
|
|
9
|
-
|
|
10
|
-
"write.md": "Create or overwrite a complete file and return anchors.",
|
|
11
|
-
"sg.md": "Search code by AST pattern and return anchored matches.",
|
|
12
|
-
"refs.md": "Find references to an identifier and return anchored usages with enclosing symbols.",
|
|
13
|
-
};
|
|
14
|
-
|
|
15
5
|
const REPLACEABLE_TOOL_GUIDELINES: Record<string, { readSeekName: string; builtInName: string; benefit: string }> = {
|
|
16
6
|
"read.md": {
|
|
17
7
|
readSeekName: "readSeek_read",
|
|
@@ -37,8 +27,7 @@ const REPLACEABLE_TOOL_GUIDELINES: Record<string, { readSeekName: string; builtI
|
|
|
37
27
|
|
|
38
28
|
const COMPACT_GUIDELINES: Record<string, string[]> = {
|
|
39
29
|
"read.md": [
|
|
40
|
-
"Use readSeek_read map or symbol mode
|
|
41
|
-
"For images and PDFs, explicitly choose one of the image modes exposed by readSeek_read.",
|
|
30
|
+
"Use readSeek_read map or symbol mode to inspect large code files without reading them in full.",
|
|
42
31
|
],
|
|
43
32
|
"edit.md": [
|
|
44
33
|
"With readSeek_edit, prefer set_line, replace_lines, and insert_after; use replace only when anchors are impractical.",
|
|
@@ -50,8 +39,7 @@ const COMPACT_GUIDELINES: Record<string, string[]> = {
|
|
|
50
39
|
"Use anchored edits rather than readSeek_write for small changes or appends to existing files.",
|
|
51
40
|
],
|
|
52
41
|
"sg.md": [
|
|
53
|
-
"Use readSeek_search for
|
|
54
|
-
"Use readSeek_grep instead of readSeek_search for plain text.",
|
|
42
|
+
"Use readSeek_search for syntax-aware code shapes; use readSeek_grep for plain text.",
|
|
55
43
|
],
|
|
56
44
|
"refs.md": [
|
|
57
45
|
"Use readSeek_refs to find every usage of an identifier before renaming or deleting it.",
|
|
@@ -96,7 +84,6 @@ export function defineToolPromptMetadata(options: {
|
|
|
96
84
|
}): ToolPromptMetadata {
|
|
97
85
|
const prompt = loadPrompt(options.promptUrl);
|
|
98
86
|
const fileName = promptFileName(options.promptUrl);
|
|
99
|
-
const compactDescription = COMPACT_DESCRIPTIONS[fileName];
|
|
100
87
|
const replaceable = REPLACEABLE_TOOL_GUIDELINES[fileName];
|
|
101
88
|
const registeredName = options.registeredName ?? replaceable?.readSeekName;
|
|
102
89
|
const preferenceGuideline = replaceable && registeredName
|
|
@@ -105,7 +92,7 @@ export function defineToolPromptMetadata(options: {
|
|
|
105
92
|
: `Use ${registeredName}; ${replaceable.benefit}`
|
|
106
93
|
: undefined;
|
|
107
94
|
return {
|
|
108
|
-
description: rewriteToolAliases(
|
|
95
|
+
description: rewriteToolAliases(firstPromptParagraph(prompt), options.toolAliases),
|
|
109
96
|
promptSnippet: rewriteToolAliases(options.promptSnippet, options.toolAliases),
|
|
110
97
|
promptGuidelines: [
|
|
111
98
|
...(preferenceGuideline ? [preferenceGuideline] : []),
|
package/src/write.ts
CHANGED
|
@@ -241,7 +241,7 @@ export function registerWriteTool(pi: ExtensionAPI, options: WriteToolOptions =
|
|
|
241
241
|
const name = options.name ?? "readSeek_write";
|
|
242
242
|
const promptMetadata = defineToolPromptMetadata({
|
|
243
243
|
promptUrl: new URL("../prompts/write.md", import.meta.url),
|
|
244
|
-
promptSnippet: "Create or
|
|
244
|
+
promptSnippet: "Create or replace a complete file with edit anchors",
|
|
245
245
|
registeredName: name,
|
|
246
246
|
});
|
|
247
247
|
const tool = registerReadSeekTool(pi, {
|
|
@@ -252,7 +252,7 @@ export function registerWriteTool(pi: ExtensionAPI, options: WriteToolOptions =
|
|
|
252
252
|
promptGuidelines: promptMetadata.promptGuidelines,
|
|
253
253
|
parameters: Type.Object({
|
|
254
254
|
path: filePathParam(),
|
|
255
|
-
content: Type.String({ description: "
|
|
255
|
+
content: Type.String({ description: "Complete file content" }),
|
|
256
256
|
map: mapParam(),
|
|
257
257
|
}),
|
|
258
258
|
async execute(_toolCallId: string, params: { path: string; content: string; map?: boolean }, _signal: AbortSignal | undefined, _onUpdate: any, ctx: any): Promise<any> {
|