@oh-my-pi/pi-coding-agent 15.3.2 → 15.4.2

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.
Files changed (193) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/dist/types/cli/file-processor.d.ts +1 -1
  3. package/dist/types/config/settings-schema.d.ts +45 -3
  4. package/dist/types/config/settings.d.ts +1 -1
  5. package/dist/types/debug/raw-sse.d.ts +2 -0
  6. package/dist/types/edit/file-read-cache.d.ts +15 -4
  7. package/dist/types/edit/index.d.ts +3 -8
  8. package/dist/types/edit/renderer.d.ts +1 -2
  9. package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
  10. package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
  11. package/dist/types/eval/js/shared/rewrite-imports.d.ts +4 -0
  12. package/dist/types/eval/js/shared/runtime.d.ts +14 -8
  13. package/dist/types/eval/py/executor.d.ts +1 -2
  14. package/dist/types/eval/py/kernel.d.ts +6 -0
  15. package/dist/types/eval/py/tool-bridge.d.ts +1 -5
  16. package/dist/types/eval/session-id.d.ts +3 -0
  17. package/dist/types/extensibility/extensions/types.d.ts +1 -3
  18. package/dist/types/hashline/anchors.d.ts +15 -9
  19. package/dist/types/hashline/constants.d.ts +0 -2
  20. package/dist/types/hashline/diff.d.ts +1 -2
  21. package/dist/types/hashline/executor.d.ts +52 -0
  22. package/dist/types/hashline/hash.d.ts +44 -93
  23. package/dist/types/hashline/index.d.ts +2 -1
  24. package/dist/types/hashline/input.d.ts +2 -9
  25. package/dist/types/hashline/recovery.d.ts +3 -9
  26. package/dist/types/hashline/tokenizer.d.ts +91 -0
  27. package/dist/types/hashline/types.d.ts +5 -7
  28. package/dist/types/modes/components/extensions/types.d.ts +0 -4
  29. package/dist/types/modes/types.d.ts +1 -0
  30. package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
  31. package/dist/types/sdk.d.ts +2 -0
  32. package/dist/types/session/agent-session.d.ts +11 -15
  33. package/dist/types/session/agent-storage.d.ts +11 -10
  34. package/dist/types/slash-commands/acp-builtins.d.ts +3 -3
  35. package/dist/types/slash-commands/types.d.ts +0 -5
  36. package/dist/types/task/executor.d.ts +2 -0
  37. package/dist/types/tool-discovery/tool-index.d.ts +0 -50
  38. package/dist/types/tools/index.d.ts +2 -8
  39. package/dist/types/tools/match-line-format.d.ts +4 -4
  40. package/dist/types/tools/output-schema-validator.d.ts +64 -0
  41. package/dist/types/tools/review.d.ts +13 -0
  42. package/dist/types/tools/search-tool-bm25.d.ts +1 -1
  43. package/dist/types/tools/search.d.ts +4 -3
  44. package/dist/types/utils/edit-mode.d.ts +1 -1
  45. package/dist/types/web/kagi.d.ts +4 -2
  46. package/dist/types/web/parallel.d.ts +4 -3
  47. package/dist/types/web/scrapers/types.d.ts +2 -1
  48. package/dist/types/web/search/index.d.ts +12 -4
  49. package/dist/types/web/search/provider.d.ts +2 -1
  50. package/dist/types/web/search/providers/anthropic.d.ts +9 -4
  51. package/dist/types/web/search/providers/base.d.ts +34 -2
  52. package/dist/types/web/search/providers/brave.d.ts +8 -1
  53. package/dist/types/web/search/providers/codex.d.ts +13 -9
  54. package/dist/types/web/search/providers/exa.d.ts +10 -1
  55. package/dist/types/web/search/providers/gemini.d.ts +20 -23
  56. package/dist/types/web/search/providers/jina.d.ts +2 -1
  57. package/dist/types/web/search/providers/kagi.d.ts +4 -1
  58. package/dist/types/web/search/providers/kimi.d.ts +10 -1
  59. package/dist/types/web/search/providers/parallel.d.ts +3 -2
  60. package/dist/types/web/search/providers/perplexity.d.ts +5 -2
  61. package/dist/types/web/search/providers/searxng.d.ts +2 -1
  62. package/dist/types/web/search/providers/synthetic.d.ts +5 -8
  63. package/dist/types/web/search/providers/tavily.d.ts +11 -4
  64. package/dist/types/web/search/providers/utils.d.ts +8 -6
  65. package/dist/types/web/search/providers/zai.d.ts +12 -3
  66. package/package.json +7 -7
  67. package/src/cli/file-processor.ts +12 -2
  68. package/src/cli.ts +0 -8
  69. package/src/commands/commit.ts +8 -8
  70. package/src/config/prompt-templates.ts +6 -6
  71. package/src/config/settings-schema.ts +47 -3
  72. package/src/config/settings.ts +5 -5
  73. package/src/debug/raw-sse.ts +68 -3
  74. package/src/edit/file-read-cache.ts +68 -25
  75. package/src/edit/index.ts +6 -37
  76. package/src/edit/renderer.ts +9 -47
  77. package/src/edit/streaming.ts +43 -56
  78. package/src/eval/__tests__/shared-executors.test.ts +520 -0
  79. package/src/eval/js/context-manager.ts +64 -53
  80. package/src/eval/js/shared/local-module-loader.ts +265 -0
  81. package/src/eval/js/shared/prelude.txt +4 -0
  82. package/src/eval/js/shared/rewrite-imports.ts +85 -0
  83. package/src/eval/js/shared/runtime.ts +129 -86
  84. package/src/eval/js/worker-core.ts +23 -38
  85. package/src/eval/py/executor.ts +155 -84
  86. package/src/eval/py/kernel.ts +10 -1
  87. package/src/eval/py/prelude.py +22 -24
  88. package/src/eval/py/runner.py +203 -85
  89. package/src/eval/py/tool-bridge.ts +17 -10
  90. package/src/eval/session-id.ts +8 -0
  91. package/src/exec/bash-executor.ts +27 -16
  92. package/src/extensibility/extensions/runner.ts +0 -1
  93. package/src/extensibility/extensions/types.ts +1 -3
  94. package/src/hashline/anchors.ts +56 -65
  95. package/src/hashline/apply.ts +29 -31
  96. package/src/hashline/constants.ts +0 -3
  97. package/src/hashline/diff-preview.ts +4 -5
  98. package/src/hashline/diff.ts +30 -4
  99. package/src/hashline/execute.ts +91 -26
  100. package/src/hashline/executor.ts +239 -0
  101. package/src/hashline/grammar.lark +12 -10
  102. package/src/hashline/hash.ts +69 -114
  103. package/src/hashline/index.ts +2 -1
  104. package/src/hashline/input.ts +48 -41
  105. package/src/hashline/prefixes.ts +21 -11
  106. package/src/hashline/recovery.ts +63 -71
  107. package/src/hashline/stream.ts +2 -2
  108. package/src/hashline/tokenizer.ts +467 -0
  109. package/src/hashline/types.ts +6 -8
  110. package/src/internal-urls/docs-index.generated.ts +7 -7
  111. package/src/modes/components/extensions/types.ts +0 -5
  112. package/src/modes/components/session-observer-overlay.ts +11 -2
  113. package/src/modes/components/settings-selector.ts +10 -1
  114. package/src/modes/components/tree-selector.ts +10 -2
  115. package/src/modes/controllers/command-controller.ts +1 -3
  116. package/src/modes/controllers/extension-ui-controller.ts +10 -11
  117. package/src/modes/controllers/selector-controller.ts +5 -5
  118. package/src/modes/theme/theme.ts +4 -2
  119. package/src/modes/types.ts +4 -1
  120. package/src/modes/utils/ui-helpers.ts +4 -0
  121. package/src/prompts/agents/explore.md +1 -1
  122. package/src/prompts/tools/ast-edit.md +1 -1
  123. package/src/prompts/tools/ast-grep.md +1 -1
  124. package/src/prompts/tools/eval.md +1 -1
  125. package/src/prompts/tools/hashline.md +73 -94
  126. package/src/prompts/tools/read.md +4 -4
  127. package/src/prompts/tools/search.md +3 -3
  128. package/src/sdk.ts +33 -26
  129. package/src/session/agent-session.ts +59 -66
  130. package/src/session/agent-storage.ts +13 -14
  131. package/src/slash-commands/acp-builtins.ts +3 -3
  132. package/src/slash-commands/types.ts +0 -6
  133. package/src/task/executor.ts +26 -57
  134. package/src/task/index.ts +8 -4
  135. package/src/tool-discovery/tool-index.ts +0 -134
  136. package/src/tools/ast-edit.ts +36 -13
  137. package/src/tools/ast-grep.ts +45 -4
  138. package/src/tools/browser/tab-worker.ts +3 -2
  139. package/src/tools/eval.ts +2 -1
  140. package/src/tools/fetch.ts +23 -14
  141. package/src/tools/index.ts +2 -8
  142. package/src/tools/irc.ts +59 -5
  143. package/src/tools/match-line-format.ts +5 -7
  144. package/src/tools/output-schema-validator.ts +132 -0
  145. package/src/tools/read.ts +142 -31
  146. package/src/tools/review.ts +23 -0
  147. package/src/tools/search-tool-bm25.ts +3 -30
  148. package/src/tools/search.ts +48 -16
  149. package/src/tools/write.ts +3 -3
  150. package/src/tools/yield.ts +32 -41
  151. package/src/utils/edit-mode.ts +1 -2
  152. package/src/utils/file-mentions.ts +2 -2
  153. package/src/web/kagi.ts +15 -6
  154. package/src/web/parallel.ts +9 -6
  155. package/src/web/scrapers/types.ts +7 -1
  156. package/src/web/scrapers/youtube.ts +13 -7
  157. package/src/web/search/index.ts +37 -11
  158. package/src/web/search/provider.ts +5 -3
  159. package/src/web/search/providers/anthropic.ts +30 -21
  160. package/src/web/search/providers/base.ts +35 -2
  161. package/src/web/search/providers/brave.ts +4 -4
  162. package/src/web/search/providers/codex.ts +118 -89
  163. package/src/web/search/providers/exa.ts +3 -2
  164. package/src/web/search/providers/gemini.ts +58 -155
  165. package/src/web/search/providers/jina.ts +4 -4
  166. package/src/web/search/providers/kagi.ts +17 -11
  167. package/src/web/search/providers/kimi.ts +29 -13
  168. package/src/web/search/providers/parallel.ts +171 -23
  169. package/src/web/search/providers/perplexity.ts +38 -37
  170. package/src/web/search/providers/searxng.ts +3 -1
  171. package/src/web/search/providers/synthetic.ts +16 -19
  172. package/src/web/search/providers/tavily.ts +23 -18
  173. package/src/web/search/providers/utils.ts +11 -17
  174. package/src/web/search/providers/zai.ts +16 -8
  175. package/dist/types/hashline/parser.d.ts +0 -7
  176. package/dist/types/mcp/discoverable-tool-metadata.d.ts +0 -7
  177. package/dist/types/tools/vim.d.ts +0 -58
  178. package/dist/types/vim/buffer.d.ts +0 -41
  179. package/dist/types/vim/commands.d.ts +0 -6
  180. package/dist/types/vim/engine.d.ts +0 -47
  181. package/dist/types/vim/parser.d.ts +0 -3
  182. package/dist/types/vim/render.d.ts +0 -25
  183. package/dist/types/vim/types.d.ts +0 -182
  184. package/src/hashline/parser.ts +0 -246
  185. package/src/mcp/discoverable-tool-metadata.ts +0 -24
  186. package/src/prompts/tools/vim.md +0 -98
  187. package/src/tools/vim.ts +0 -949
  188. package/src/vim/buffer.ts +0 -309
  189. package/src/vim/commands.ts +0 -382
  190. package/src/vim/engine.ts +0 -2409
  191. package/src/vim/parser.ts +0 -134
  192. package/src/vim/render.ts +0 -252
  193. package/src/vim/types.ts +0 -197
@@ -1,246 +0,0 @@
1
- import { ABORT_MARKER, ABORT_WARNING, BEGIN_PATCH_MARKER, END_PATCH_MARKER, RANGE_INTERIOR_HASH } from "./constants";
2
- import {
3
- computeLineHash,
4
- describeAnchorExamples,
5
- HL_BODY_SEP_RE_RAW,
6
- HL_FILE_PREFIX,
7
- HL_HASH_CAPTURE_RE_RAW,
8
- HL_OP_CHARS,
9
- HL_OP_INSERT_AFTER,
10
- HL_OP_INSERT_BEFORE,
11
- HL_OP_REPLACE,
12
- } from "./hash";
13
- import type { Anchor, HashlineCursor, HashlineEdit } from "./types";
14
-
15
- // Leniently accept anchors copied from read/search output:
16
- // - optional leading line-marker decoration (`*`, `>`, `+`, `-`)
17
- // - the required `LINE+HASH`
18
- // - an optional trailing `|TEXT` body (or anything after the hash) so users
19
- // can paste a full `LINE+HASH|TEXT` line verbatim.
20
- const LID_CAPTURE_RE = new RegExp(`^\\s*[>+\\-*]*\\s*${HL_HASH_CAPTURE_RE_RAW}(?:\\|.*)?\\s*$`);
21
- const regexEscape = (str: string): string => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22
-
23
- function parseLid(raw: string, lineNum: number): Anchor {
24
- const match = LID_CAPTURE_RE.exec(raw);
25
- if (!match) {
26
- throw new Error(
27
- `line ${lineNum}: expected a full anchor such as ${describeAnchorExamples("119")}; ` +
28
- `got ${JSON.stringify(raw)}.`,
29
- );
30
- }
31
- return { line: Number.parseInt(match[1], 10), hash: match[2] };
32
- }
33
-
34
- interface ParsedRange {
35
- start: Anchor;
36
- end: Anchor;
37
- }
38
-
39
- function parseRange(raw: string, lineNum: number): ParsedRange {
40
- if (!raw.includes("..")) {
41
- const start = parseLid(raw, lineNum);
42
- return { start, end: { ...start } };
43
- }
44
- const [startRaw, endRaw, extra] = raw.split("..");
45
- if (extra !== undefined || !startRaw || !endRaw) {
46
- throw new Error(
47
- `line ${lineNum}: range must include exactly two full anchors separated by "..". ` +
48
- `For a one-line edit, repeat the same anchor on both sides.`,
49
- );
50
- }
51
- const start = parseLid(startRaw, lineNum);
52
- const end = parseLid(endRaw, lineNum);
53
- if (end.line < start.line) {
54
- throw new Error(`line ${lineNum}: range ${startRaw}..${endRaw} ends before it starts.`);
55
- }
56
- if (end.line === start.line && end.hash !== start.hash) {
57
- throw new Error(`line ${lineNum}: range ${startRaw}..${endRaw} uses two different hashes for the same line.`);
58
- }
59
- return { start, end };
60
- }
61
-
62
- function expandRange(range: ParsedRange): Anchor[] {
63
- const anchors: Anchor[] = [];
64
- for (let line = range.start.line; line <= range.end.line; line++) {
65
- const hash =
66
- line === range.start.line ? range.start.hash : line === range.end.line ? range.end.hash : RANGE_INTERIOR_HASH;
67
- anchors.push({ line, hash });
68
- }
69
- return anchors;
70
- }
71
-
72
- function parseInsertTarget(raw: string, lineNum: number, kind: "before" | "after"): HashlineCursor {
73
- if (raw === "BOF") return { kind: "bof" };
74
- if (raw === "EOF") return { kind: "eof" };
75
- const cursorKind = kind === "before" ? "before_anchor" : "after_anchor";
76
- return { kind: cursorKind, anchor: parseLid(raw, lineNum) };
77
- }
78
-
79
- /**
80
- * Decide how to interpret the optional `|TEXT` body captured on an insert
81
- * op line:
82
- * - For BOF/EOF cursors the body is always treated as an inline payload
83
- * line (there's no anchor hash to compare against).
84
- * - For anchored cursors, compute the hash of TEXT at the anchor's line
85
- * number. If it matches the anchor's hash, the body is just a verbatim
86
- * copy of the anchored line — discard it, payload must come from the
87
- * following lines as usual.
88
- * - Otherwise the body is the first (or only) payload line for this op.
89
- */
90
- function resolveInlineInsertBody(cursor: HashlineCursor, body: string | undefined): string | undefined {
91
- if (body === undefined) return undefined;
92
- if (cursor.kind !== "before_anchor" && cursor.kind !== "after_anchor") return body;
93
- const { line, hash } = cursor.anchor;
94
- if (computeLineHash(line, body) === hash) return undefined;
95
- return body;
96
- }
97
-
98
- // Insert ops leniently accept a trailing `|TEXT` body on the op line itself
99
- // (e.g. `»502zk|\tconst foo = ...`). The anchor token excludes `|` so the body
100
- // is captured separately; resolveInlineInsertBody decides whether to treat the
101
- // captured text as a verbatim anchor decoration (when its hash matches the
102
- // anchor's) or as an inline payload line.
103
- const INSERT_BEFORE_OP_RE = new RegExp(
104
- `^${regexEscape(HL_OP_INSERT_BEFORE)}\\s*([^|\\s]+)(?:${HL_BODY_SEP_RE_RAW}(.*))?\\s*$`,
105
- );
106
- const INSERT_AFTER_OP_RE = new RegExp(
107
- `^${regexEscape(HL_OP_INSERT_AFTER)}\\s*([^|\\s]+)(?:${HL_BODY_SEP_RE_RAW}(.*))?\\s*$`,
108
- );
109
- const REPLACE_OP_RE = new RegExp(`^${regexEscape(HL_OP_REPLACE)}\\s*([^\\s+<\\-=]\\S*)\\s*$`);
110
-
111
- function isEnvelopeOrAbortMarkerLine(line: string): boolean {
112
- const trimmed = line.trimEnd();
113
- return trimmed === BEGIN_PATCH_MARKER || trimmed === END_PATCH_MARKER || trimmed === ABORT_MARKER;
114
- }
115
-
116
- function isPayloadTerminatorLine(line: string): boolean {
117
- const first = line[0];
118
- return (
119
- first === HL_FILE_PREFIX ||
120
- (first !== undefined && HL_OP_CHARS.includes(first)) ||
121
- isEnvelopeOrAbortMarkerLine(line)
122
- );
123
- }
124
-
125
- export function cloneCursor(cursor: HashlineCursor): HashlineCursor {
126
- if (cursor.kind === "before_anchor") return { kind: "before_anchor", anchor: { ...cursor.anchor } };
127
- if (cursor.kind === "after_anchor") return { kind: "after_anchor", anchor: { ...cursor.anchor } };
128
- return cursor;
129
- }
130
-
131
- function collectPayload(
132
- lines: string[],
133
- startIndex: number,
134
- opLineNum: number,
135
- requirePayload: boolean,
136
- ): { payload: string[]; nextIndex: number } {
137
- const payload: string[] = [];
138
- let index = startIndex;
139
- while (index < lines.length) {
140
- const line = lines[index];
141
- if (isPayloadTerminatorLine(line)) break;
142
- payload.push(line);
143
- index++;
144
- }
145
- if (payload.length === 0 && requirePayload) {
146
- throw new Error(
147
- `line ${opLineNum}: ${HL_OP_INSERT_BEFORE} and ${HL_OP_INSERT_AFTER} operations require at least one verbatim payload line.`,
148
- );
149
- }
150
- return { payload, nextIndex: index };
151
- }
152
-
153
- export function parseHashline(diff: string): HashlineEdit[] {
154
- return parseHashlineWithWarnings(diff).edits;
155
- }
156
-
157
- export function parseHashlineWithWarnings(diff: string): { edits: HashlineEdit[]; warnings: string[] } {
158
- const edits: HashlineEdit[] = [];
159
- const warnings: string[] = [];
160
- const lines = diff.split(/\r?\n/);
161
- if (diff.endsWith("\n") && lines.at(-1) === "") lines.pop();
162
- let editIndex = 0;
163
-
164
- const pushInsert = (cursor: HashlineCursor, text: string, lineNum: number) => {
165
- edits.push({ kind: "insert", cursor: cloneCursor(cursor), text, lineNum, index: editIndex++ });
166
- };
167
-
168
- for (let i = 0; i < lines.length; ) {
169
- const lineNum = i + 1;
170
- const line = lines[i];
171
-
172
- if (line.trim().length === 0) {
173
- i++;
174
- continue;
175
- }
176
- if (line === END_PATCH_MARKER) {
177
- break;
178
- }
179
- if (line === ABORT_MARKER) {
180
- warnings.push(ABORT_WARNING);
181
- break;
182
- }
183
- if (line === BEGIN_PATCH_MARKER) {
184
- i++;
185
- continue;
186
- }
187
-
188
- const insertBeforeMatch = INSERT_BEFORE_OP_RE.exec(line);
189
- if (insertBeforeMatch) {
190
- const cursor = parseInsertTarget(insertBeforeMatch[1], lineNum, "before");
191
- const inlineBody = resolveInlineInsertBody(cursor, insertBeforeMatch[2]);
192
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, inlineBody === undefined);
193
- if (inlineBody !== undefined) pushInsert(cursor, inlineBody, lineNum);
194
- for (const text of payload) pushInsert(cursor, text, lineNum);
195
- i = nextIndex;
196
- continue;
197
- }
198
-
199
- const insertAfterMatch = INSERT_AFTER_OP_RE.exec(line);
200
- if (insertAfterMatch) {
201
- const cursor = parseInsertTarget(insertAfterMatch[1], lineNum, "after");
202
- const inlineBody = resolveInlineInsertBody(cursor, insertAfterMatch[2]);
203
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, inlineBody === undefined);
204
- if (inlineBody !== undefined) pushInsert(cursor, inlineBody, lineNum);
205
- for (const text of payload) pushInsert(cursor, text, lineNum);
206
- i = nextIndex;
207
- continue;
208
- }
209
-
210
- const replaceMatch = REPLACE_OP_RE.exec(line);
211
- if (replaceMatch) {
212
- const range = parseRange(replaceMatch[1], lineNum);
213
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, false);
214
- if (payload.length > 0) {
215
- for (const text of payload) {
216
- edits.push({
217
- kind: "insert",
218
- cursor: { kind: "before_anchor", anchor: { ...range.start } },
219
- text,
220
- lineNum,
221
- index: editIndex++,
222
- });
223
- }
224
- }
225
- for (const anchor of expandRange(range)) {
226
- edits.push({ kind: "delete", anchor, lineNum, index: editIndex++ });
227
- }
228
- i = nextIndex;
229
- continue;
230
- }
231
-
232
- if (isPayloadTerminatorLine(line) || /^[-@\u00B6]/u.test(line)) {
233
- throw new Error(
234
- `line ${lineNum}: unrecognized op. Use ${HL_OP_INSERT_BEFORE}ANCHOR (insert before), ${HL_OP_INSERT_AFTER}ANCHOR (insert after), or ${HL_OP_REPLACE}A..B (replace/delete). ` +
235
- `Got ${JSON.stringify(line)}.`,
236
- );
237
- }
238
-
239
- throw new Error(
240
- `line ${lineNum}: payload line has no preceding ${HL_OP_INSERT_BEFORE}, ${HL_OP_INSERT_AFTER}, or ${HL_OP_REPLACE} operation. ` +
241
- `Got ${JSON.stringify(line)}.`,
242
- );
243
- }
244
-
245
- return { edits, warnings };
246
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Back-compat re-export layer.
3
- * All types and functions have moved to src/tool-discovery/tool-index.ts.
4
- * This file exists solely so existing imports continue to compile without changes.
5
- */
6
- export type {
7
- DiscoverableMCPSearchDocument,
8
- DiscoverableMCPSearchIndex,
9
- DiscoverableMCPSearchResult,
10
- DiscoverableMCPTool,
11
- DiscoverableMCPToolServerSummary,
12
- DiscoverableMCPToolSummary,
13
- } from "../tool-discovery/tool-index";
14
-
15
- export {
16
- buildDiscoverableMCPSearchIndex,
17
- collectDiscoverableMCPTools,
18
- formatDiscoverableMCPToolServerSummary,
19
- getDiscoverableMCPTool,
20
- isMCPToolName,
21
- searchDiscoverableMCPTools,
22
- selectDiscoverableMCPToolNamesByServer,
23
- summarizeDiscoverableMCPTools,
24
- } from "../tool-discovery/tool-index";
@@ -1,98 +0,0 @@
1
- Vim-style `edit` mode. The tool name stays `edit`; every call requires `file`, and the buffer loads automatically on first use.
2
- - `{"file": "path"}` - view file
3
- - `{"file": "path", "steps": [{"kbd": ["…"], "insert": "…"}]}` - edit file
4
-
5
- **Multi-location edits: always edit highest line number first (bottom-up).** Each insert shifts lines below it.
6
-
7
- ## steps vs kbd vs insert
8
-
9
- `steps` = ordered editing steps. Each step runs `kbd`, then optionally types `insert`.
10
- `kbd` = Vim commands only (`dd`, `G`, `o`, `cc`, `gg`, etc.).
11
- `insert` = raw text content to type into the buffer.
12
- `o`/`O` already create a new line — do not start `insert` with `\n`. A trailing `\n` in `insert` adds an extra blank line.
13
-
14
- Never put text content in `kbd`. Only Vim keystrokes go there.
15
- - BAD: `{"steps": [{"kbd": ["1Gohello world<Esc>"]}]}`
16
- - BAD: `{"steps": [{"kbd": ["1Go", "hello world"]}]}`
17
- - BAD: `{"steps": [{"kbd": ["1Ao"], "insert": "text"}]}`
18
- - GOOD: `{"steps": [{"kbd": ["1Go"], "insert": "hello world"}]}`
19
-
20
- If a step uses `insert`, the last `kbd` entry in that step must leave INSERT mode active (`o`, `O`, `i`, `a`, `A`, `cc`, `C`, `s`, `S`).
21
-
22
- Each non-final `kbd` entry inside a step must end in NORMAL mode (add `<Esc>`).
23
-
24
- Between steps, the tool auto-exits INSERT mode.
25
-
26
- Whitespace in `kbd` is literal. Do not use spaces as separators between keys; `ggdGi` is one sequence, not `ggdG i`.
27
-
28
- Common mistake: `Ni` means "insert N copies", NOT "insert at line N". To insert at line N, use `NGo` (below) or `NGO` (above).
29
- ## Editing patterns
30
-
31
- `NGo` = new line BELOW line N. `NGO` = new line ABOVE line N.
32
-
33
- Insert new line after line 3:
34
- ```json
35
- {"file": "f.py", "steps": [{"kbd": ["3Go"], "insert": " new line here"}]}
36
- ```
37
-
38
- Insert new line before line 3:
39
- ```json
40
- {"file": "f.py", "steps": [{"kbd": ["3GO"], "insert": " new line here"}]}
41
- ```
42
-
43
- Replace line N:
44
- ```json
45
- {"file": "f.py", "steps": [{"kbd": ["5Gcc"], "insert": " replacement content"}]}
46
- ```
47
-
48
- Replace entire file. `ggdGi` = go to top, delete all, enter INSERT. Use that exact sequence when rewriting the whole file:
49
- ```json
50
- {"file": "f.py", "steps": [{"kbd": ["ggdGi"], "insert": "entire new file content"}]}
51
- ```
52
-
53
- Multi-location edit — edit **highest line number first** (bottom-up) so inserts don't shift later targets:
54
- ```json
55
- {"file": "f.py", "steps": [
56
- {"kbd": ["8Go"], "insert": " print(result)"},
57
- {"kbd": ["3Go"], "insert": "def helper(x):\n return x + 1"}
58
- ]}
59
- ```
60
- Each `o`/`O` insert adds lines, shifting everything below. Bottom-up order keeps all line numbers valid. Use `\n` within `insert` for multi-line content.
61
-
62
- Navigation or search step without insert:
63
- ```json
64
- {"file": "f.py", "steps": [{"kbd": ["/pattern<CR>"]}]}
65
- ```
66
-
67
- Find and replace:
68
- ```json
69
- {"file": "f.py", "steps": [{"kbd": [":%s/old/new/g<CR>"]}]}
70
- ```
71
-
72
- Delete line range:
73
- ```json
74
- {"file": "f.py", "steps": [{"kbd": [":3,5d<CR>"]}]}
75
- ```
76
- Ex commands always start with `:` and end with `<CR>`. `3,5d` without `:` is NOT an ex command — it is interpreted as normal-mode keystrokes and will fail.
77
-
78
- ## Undo mistakes
79
- - `{"file": "f.py", "steps": [{"kbd": ["u"]}]}` - undo last change
80
- - `{"file": "f.py", "steps": [{"kbd": ["3u"]}]}` - undo last 3 changes
81
-
82
- `:e!` reloads from disk. Warning: because non-paused calls auto-save, `:e!` reloads your last saved state, not the original file. Use `u` to undo instead. If stuck, use `ggdGi` with the full desired file content.
83
-
84
- ## Session persistence
85
-
86
- The edit buffer in vim mode persists across tool calls. Cursor position, undo history, and file state are maintained until you close the buffer. Auto-save happens once after all steps in a non-paused call complete.
87
-
88
- ## Supported
89
-
90
- Keys: `<Esc>` `<CR>` `<BS>` `<Tab>` `<C-d>` `<C-u>` `<C-r>` `<C-w>` `<C-o>`
91
- Motions: `h j k l <Space> w b e 0 $ ^ + - _ gg G { } f F t T % H M L ; ,` with counts
92
- Operators: `d c y p` with motions and text objects (`iw aw ip ap i" a" i( a( i{ a{`)
93
- Insert: `i a o O I A cc C s S R` - these all enter INSERT mode; do not add another `i` after them
94
- Visual: `v V` with `d y c > < ~ r u U p P o J`
95
- Other: `.` repeat, `u`/`<C-r>` undo/redo, `/pattern<CR>` search, `n N * #`, `gv` `gJ` `gU` `gu` `ZZ` `ZQ`
96
- Ex: `:w` `:q` `:wq` `:e` `:e!` `:N` `:s///` `:%s///` `:N,Md` `:%d` `:N,Mt N` `:sort` `:j` `:j!` `:g/pattern/d` `:v/pattern/d`
97
- Addresses: absolute line numbers, `.`, `$`, and `+N`/`-N` relative offsets, including ranges like `:.,$d` and `:.+2,$g/pattern/d`
98
- More ex: `:up` `:N,My` `:put` `:put!` `:N,Mco $` `:N,Mm $`