@asterism-app/builtin-api 1.2.0 → 1.2.1
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/examples/package.json +2 -2
- package/package.json +1 -1
- package/src/search.ts +2 -2
- package/src/text.ts +4 -4
- package/src/tools.ts +5 -11
package/examples/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"react-intl": "^12.1.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@asterism-app/sdk": "2.
|
|
19
|
-
"@asterism-app/builtin-api": "1.2.
|
|
18
|
+
"@asterism-app/sdk": "2.5.0",
|
|
19
|
+
"@asterism-app/builtin-api": "1.2.1",
|
|
20
20
|
"@asterism-app/plugin-build": "1.0.1",
|
|
21
21
|
"typescript": "^7.0.2",
|
|
22
22
|
"@types/node": "^26.6.1",
|
package/package.json
CHANGED
package/src/search.ts
CHANGED
|
@@ -7,7 +7,7 @@ const selection = {
|
|
|
7
7
|
limit: z.number().int().positive().max(2000).optional().describe("Maximum returned matching lines, or entries in another resource-specific view; defaults to 500, maximum 2000. Context lines are bounded only by the output-byte budget."),
|
|
8
8
|
};
|
|
9
9
|
const globGuidelines = [
|
|
10
|
-
"Globs use ripgrep semantics. A pattern without '/'
|
|
10
|
+
"Globs use ripgrep semantics. A pattern without '/' matches filenames at any depth.",
|
|
11
11
|
"Positive globs override hidden and ignore rules for entries they match. A directory that remains excluded is skipped with its descendants.",
|
|
12
12
|
];
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ export const Find = defineTool({
|
|
|
19
19
|
"target selects the search scope and resource-specific file filtering according to the resource implementation's schema.",
|
|
20
20
|
],
|
|
21
21
|
argsSchema: z.strictObject({
|
|
22
|
-
pattern: pattern.describe("File glob relative to the selected search directory, using '/' separators
|
|
22
|
+
pattern: pattern.describe("File glob relative to the selected search directory, using '/' separators."),
|
|
23
23
|
...selection,
|
|
24
24
|
}).describe("A file glob and search selection options."),
|
|
25
25
|
});
|
package/src/text.ts
CHANGED
|
@@ -4,15 +4,15 @@ export const lineAnchorSchema = z.strictObject({
|
|
|
4
4
|
line: z.number().int().positive().describe("1-based line number copied from an anchored read, grep, edit, or replace result."),
|
|
5
5
|
hash: z.string().regex(/^[0-9A-HJKMNP-TV-Z]{4}$/).describe("The exact four-character content hash after # in an anchored read, grep, edit, or replace result."),
|
|
6
6
|
}).describe("A LINE#HASH reference to the current content at one line.");
|
|
7
|
-
const body = z.array(z.string().regex(/^[^\r\n]*$/).describe("One content
|
|
7
|
+
const body = z.array(z.string().regex(/^[^\r\n]*$/).describe("One line of new content without the LINE#HASH prefix or a line terminator. An empty string represents a blank line."))
|
|
8
8
|
.min(1).describe("New text lines to insert or use as replacement content.");
|
|
9
9
|
const anchor = lineAnchorSchema.describe("The first affected line, or the preserved line next to an insertion.");
|
|
10
|
-
const end = lineAnchorSchema.optional().describe("Inclusive last line for replace/delete.
|
|
10
|
+
const end = lineAnchorSchema.optional().describe("Inclusive last line for replace/delete. Omit only for a single-line edit: without end, even a multi-line body replaces only the anchor line and leaves following lines in place.");
|
|
11
11
|
export const editOperationSchema = z.discriminatedUnion("op", [
|
|
12
12
|
z.strictObject({ op: z.literal("replace").describe("Replace the selected lines with body."), anchor, end, body }),
|
|
13
13
|
z.strictObject({ op: z.literal("delete").describe("Delete the selected lines."), anchor, end }),
|
|
14
|
-
z.strictObject({ op: z.literal("insert_after").describe("Insert
|
|
15
|
-
z.strictObject({ op: z.literal("insert_before").describe("Insert
|
|
14
|
+
z.strictObject({ op: z.literal("insert_after").describe("Insert only new lines after the anchor line. The existing anchor line stays in place."), anchor, body }),
|
|
15
|
+
z.strictObject({ op: z.literal("insert_before").describe("Insert only new lines before the anchor line. The existing anchor line stays in place."), anchor, body }),
|
|
16
16
|
z.strictObject({ op: z.literal("append").describe("Append body to the target's text."), body }),
|
|
17
17
|
z.strictObject({ op: z.literal("prepend").describe("Prepend body to the target's text."), body }),
|
|
18
18
|
]).describe("Replace/delete an inclusive anchored range, insert beside a preserved anchor, or append/prepend without anchors.");
|
package/src/tools.ts
CHANGED
|
@@ -45,18 +45,12 @@ export const Edit = defineTool({
|
|
|
45
45
|
name: "edit",
|
|
46
46
|
description: "Edit selected lines in existing text using hashline operations. LINE#HASH anchors come from the latest read, grep, edit, or replace result.",
|
|
47
47
|
guidelines: [
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"insert_before/insert_after preserve the anchor line. body contains the new lines.",
|
|
52
|
-
"append/prepend take body. Each body item is one text line; an empty string represents a blank line.",
|
|
53
|
-
"All operations refer to the same pre-edit content and commit as one batch. Anchor or overlap failures preserve the original text.",
|
|
54
|
-
"Replace/delete ranges conflict when they share original lines. Insertions can share range boundaries; an insertion strictly inside a replaced or deleted range conflicts. Insertions at the same original gap appear in edits array order.",
|
|
55
|
-
"A successful edit reports the line counts and fresh LINE#HASH anchors for subsequent edits. The user-facing result contains the diff.",
|
|
56
|
-
"Anchor mismatch results include current-line or shifted candidates.",
|
|
48
|
+
"args.edits can group several changes to the same target in one call. Every operation uses coordinates from the same pre-edit text. Copy anchor and end line numbers and hashes from the latest anchored tool output.",
|
|
49
|
+
"A successful edit returns updated anchors for subsequent edits. Pre-edit anchors below an insertion or deletion may be stale even if the line content did not change.",
|
|
50
|
+
"The batch commits only if all anchors and ranges validate. Replace/delete ranges cannot share original lines. Insertions can share range boundaries but cannot fall inside a replaced or deleted range. Insertions at the same gap follow array order.",
|
|
57
51
|
],
|
|
58
52
|
argsSchema: z.strictObject({
|
|
59
|
-
edits: z.array(editOperationSchema).min(1).max(500).describe("One to 500
|
|
53
|
+
edits: z.array(editOperationSchema).min(1).max(500).describe("One to 500 operations on the same pre-edit text."),
|
|
60
54
|
}).describe("A complete batch of line-based edit operations. The target is selected separately."),
|
|
61
55
|
});
|
|
62
56
|
|
|
@@ -90,7 +84,7 @@ export const Replace = defineTool({
|
|
|
90
84
|
"Literal mode matches find as text and inserts replace verbatim. Regex mode uses JavaScript regular expressions and replacement syntax.",
|
|
91
85
|
"All non-overlapping matches are replaced. flags applies in both modes; global matching is always enabled.",
|
|
92
86
|
"No matches returns an error without changing the target. Matches that produce identical content succeed without writing.",
|
|
93
|
-
"The receipt reports the match count and
|
|
87
|
+
"The receipt reports the match count and updated anchors for subsequent edits.",
|
|
94
88
|
],
|
|
95
89
|
argsSchema: z.strictObject({
|
|
96
90
|
find: z.string().min(1).describe("Non-empty text to find, or a JavaScript regular expression source when regex is true."),
|