@oh-my-pi/pi-coding-agent 15.3.1 → 15.4.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.
Files changed (200) hide show
  1. package/CHANGELOG.md +119 -0
  2. package/dist/types/cli/auth-gateway-cli.d.ts +1 -1
  3. package/dist/types/cli/file-processor.d.ts +1 -1
  4. package/dist/types/config/settings-schema.d.ts +45 -3
  5. package/dist/types/config/settings.d.ts +1 -1
  6. package/dist/types/debug/raw-sse.d.ts +2 -0
  7. package/dist/types/edit/file-read-cache.d.ts +15 -4
  8. package/dist/types/edit/index.d.ts +3 -8
  9. package/dist/types/edit/renderer.d.ts +1 -2
  10. package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
  11. package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
  12. package/dist/types/eval/js/shared/rewrite-imports.d.ts +4 -0
  13. package/dist/types/eval/js/shared/runtime.d.ts +14 -8
  14. package/dist/types/eval/py/executor.d.ts +1 -2
  15. package/dist/types/eval/py/kernel.d.ts +6 -0
  16. package/dist/types/eval/py/tool-bridge.d.ts +1 -5
  17. package/dist/types/eval/session-id.d.ts +3 -0
  18. package/dist/types/extensibility/extensions/types.d.ts +1 -3
  19. package/dist/types/hashline/anchors.d.ts +15 -9
  20. package/dist/types/hashline/constants.d.ts +0 -2
  21. package/dist/types/hashline/diff.d.ts +1 -2
  22. package/dist/types/hashline/executor.d.ts +52 -0
  23. package/dist/types/hashline/hash.d.ts +44 -93
  24. package/dist/types/hashline/index.d.ts +2 -1
  25. package/dist/types/hashline/input.d.ts +2 -9
  26. package/dist/types/hashline/recovery.d.ts +3 -9
  27. package/dist/types/hashline/tokenizer.d.ts +91 -0
  28. package/dist/types/hashline/types.d.ts +5 -7
  29. package/dist/types/modes/components/extensions/types.d.ts +0 -4
  30. package/dist/types/modes/types.d.ts +1 -0
  31. package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
  32. package/dist/types/sdk.d.ts +2 -0
  33. package/dist/types/session/agent-session.d.ts +11 -15
  34. package/dist/types/session/agent-storage.d.ts +11 -10
  35. package/dist/types/slash-commands/acp-builtins.d.ts +3 -3
  36. package/dist/types/slash-commands/types.d.ts +0 -5
  37. package/dist/types/task/executor.d.ts +2 -0
  38. package/dist/types/task/types.d.ts +8 -0
  39. package/dist/types/tool-discovery/tool-index.d.ts +0 -50
  40. package/dist/types/tools/index.d.ts +2 -8
  41. package/dist/types/tools/match-line-format.d.ts +4 -4
  42. package/dist/types/tools/output-schema-validator.d.ts +64 -0
  43. package/dist/types/tools/review.d.ts +13 -0
  44. package/dist/types/tools/search-tool-bm25.d.ts +1 -1
  45. package/dist/types/tools/search.d.ts +4 -3
  46. package/dist/types/utils/edit-mode.d.ts +1 -1
  47. package/dist/types/web/kagi.d.ts +4 -2
  48. package/dist/types/web/parallel.d.ts +4 -3
  49. package/dist/types/web/scrapers/types.d.ts +2 -1
  50. package/dist/types/web/search/index.d.ts +12 -4
  51. package/dist/types/web/search/provider.d.ts +2 -1
  52. package/dist/types/web/search/providers/anthropic.d.ts +9 -4
  53. package/dist/types/web/search/providers/base.d.ts +34 -2
  54. package/dist/types/web/search/providers/brave.d.ts +8 -1
  55. package/dist/types/web/search/providers/codex.d.ts +13 -9
  56. package/dist/types/web/search/providers/exa.d.ts +10 -1
  57. package/dist/types/web/search/providers/gemini.d.ts +20 -23
  58. package/dist/types/web/search/providers/jina.d.ts +2 -1
  59. package/dist/types/web/search/providers/kagi.d.ts +4 -1
  60. package/dist/types/web/search/providers/kimi.d.ts +10 -1
  61. package/dist/types/web/search/providers/parallel.d.ts +3 -2
  62. package/dist/types/web/search/providers/perplexity.d.ts +5 -2
  63. package/dist/types/web/search/providers/searxng.d.ts +2 -1
  64. package/dist/types/web/search/providers/synthetic.d.ts +5 -8
  65. package/dist/types/web/search/providers/tavily.d.ts +11 -4
  66. package/dist/types/web/search/providers/utils.d.ts +8 -6
  67. package/dist/types/web/search/providers/zai.d.ts +12 -3
  68. package/package.json +7 -7
  69. package/src/cli/auth-gateway-cli.ts +71 -2
  70. package/src/cli/file-processor.ts +12 -2
  71. package/src/cli.ts +0 -8
  72. package/src/commands/auth-gateway.ts +2 -0
  73. package/src/commands/commit.ts +8 -8
  74. package/src/config/prompt-templates.ts +6 -6
  75. package/src/config/settings-schema.ts +47 -3
  76. package/src/config/settings.ts +5 -5
  77. package/src/debug/raw-sse.ts +68 -3
  78. package/src/edit/file-read-cache.ts +68 -25
  79. package/src/edit/index.ts +6 -37
  80. package/src/edit/renderer.ts +9 -47
  81. package/src/edit/streaming.ts +43 -56
  82. package/src/eval/__tests__/shared-executors.test.ts +520 -0
  83. package/src/eval/js/context-manager.ts +64 -53
  84. package/src/eval/js/shared/local-module-loader.ts +265 -0
  85. package/src/eval/js/shared/prelude.txt +4 -0
  86. package/src/eval/js/shared/rewrite-imports.ts +85 -0
  87. package/src/eval/js/shared/runtime.ts +129 -86
  88. package/src/eval/js/worker-core.ts +23 -38
  89. package/src/eval/py/executor.ts +155 -84
  90. package/src/eval/py/kernel.ts +10 -1
  91. package/src/eval/py/prelude.py +22 -24
  92. package/src/eval/py/runner.py +203 -85
  93. package/src/eval/py/tool-bridge.ts +17 -10
  94. package/src/eval/session-id.ts +8 -0
  95. package/src/exec/bash-executor.ts +27 -16
  96. package/src/extensibility/extensions/runner.ts +0 -1
  97. package/src/extensibility/extensions/types.ts +1 -3
  98. package/src/extensibility/plugins/marketplace/manager.ts +20 -1
  99. package/src/hashline/anchors.ts +56 -65
  100. package/src/hashline/apply.ts +29 -31
  101. package/src/hashline/constants.ts +0 -3
  102. package/src/hashline/diff-preview.ts +4 -5
  103. package/src/hashline/diff.ts +30 -4
  104. package/src/hashline/execute.ts +91 -26
  105. package/src/hashline/executor.ts +239 -0
  106. package/src/hashline/grammar.lark +12 -10
  107. package/src/hashline/hash.ts +69 -114
  108. package/src/hashline/index.ts +2 -1
  109. package/src/hashline/input.ts +48 -41
  110. package/src/hashline/prefixes.ts +21 -11
  111. package/src/hashline/recovery.ts +63 -71
  112. package/src/hashline/stream.ts +2 -2
  113. package/src/hashline/tokenizer.ts +467 -0
  114. package/src/hashline/types.ts +6 -8
  115. package/src/internal-urls/docs-index.generated.ts +9 -8
  116. package/src/lsp/config.ts +87 -22
  117. package/src/modes/components/extensions/types.ts +0 -5
  118. package/src/modes/components/session-observer-overlay.ts +11 -2
  119. package/src/modes/components/tree-selector.ts +10 -2
  120. package/src/modes/controllers/command-controller.ts +1 -3
  121. package/src/modes/controllers/extension-ui-controller.ts +10 -11
  122. package/src/modes/controllers/selector-controller.ts +5 -5
  123. package/src/modes/types.ts +4 -1
  124. package/src/modes/utils/ui-helpers.ts +4 -0
  125. package/src/prompts/agents/explore.md +1 -1
  126. package/src/prompts/tools/ast-edit.md +1 -1
  127. package/src/prompts/tools/ast-grep.md +1 -1
  128. package/src/prompts/tools/eval.md +1 -1
  129. package/src/prompts/tools/hashline.md +73 -94
  130. package/src/prompts/tools/read.md +4 -4
  131. package/src/prompts/tools/search.md +3 -3
  132. package/src/sdk.ts +21 -24
  133. package/src/session/agent-session.ts +59 -66
  134. package/src/session/agent-storage.ts +13 -14
  135. package/src/slash-commands/acp-builtins.ts +3 -3
  136. package/src/slash-commands/types.ts +0 -6
  137. package/src/task/executor.ts +55 -57
  138. package/src/task/index.ts +8 -4
  139. package/src/task/render.ts +53 -1
  140. package/src/task/types.ts +8 -0
  141. package/src/tool-discovery/tool-index.ts +0 -134
  142. package/src/tools/ast-edit.ts +36 -13
  143. package/src/tools/ast-grep.ts +45 -4
  144. package/src/tools/browser/tab-worker.ts +3 -2
  145. package/src/tools/eval.ts +2 -1
  146. package/src/tools/fetch.ts +23 -14
  147. package/src/tools/index.ts +2 -8
  148. package/src/tools/irc.ts +59 -5
  149. package/src/tools/jtd-to-json-schema.ts +5 -1
  150. package/src/tools/match-line-format.ts +5 -7
  151. package/src/tools/output-schema-validator.ts +132 -0
  152. package/src/tools/read.ts +142 -63
  153. package/src/tools/review.ts +23 -0
  154. package/src/tools/search-tool-bm25.ts +3 -30
  155. package/src/tools/search.ts +48 -16
  156. package/src/tools/write.ts +3 -3
  157. package/src/tools/yield.ts +32 -41
  158. package/src/utils/edit-mode.ts +1 -2
  159. package/src/utils/file-mentions.ts +2 -2
  160. package/src/web/kagi.ts +15 -6
  161. package/src/web/parallel.ts +9 -6
  162. package/src/web/scrapers/types.ts +7 -1
  163. package/src/web/scrapers/youtube.ts +13 -7
  164. package/src/web/search/index.ts +37 -11
  165. package/src/web/search/provider.ts +5 -3
  166. package/src/web/search/providers/anthropic.ts +30 -21
  167. package/src/web/search/providers/base.ts +35 -2
  168. package/src/web/search/providers/brave.ts +4 -4
  169. package/src/web/search/providers/codex.ts +118 -89
  170. package/src/web/search/providers/exa.ts +3 -2
  171. package/src/web/search/providers/gemini.ts +58 -155
  172. package/src/web/search/providers/jina.ts +4 -4
  173. package/src/web/search/providers/kagi.ts +17 -11
  174. package/src/web/search/providers/kimi.ts +29 -13
  175. package/src/web/search/providers/parallel.ts +171 -23
  176. package/src/web/search/providers/perplexity.ts +38 -37
  177. package/src/web/search/providers/searxng.ts +3 -1
  178. package/src/web/search/providers/synthetic.ts +16 -19
  179. package/src/web/search/providers/tavily.ts +23 -18
  180. package/src/web/search/providers/utils.ts +11 -17
  181. package/src/web/search/providers/zai.ts +16 -8
  182. package/dist/types/hashline/parser.d.ts +0 -7
  183. package/dist/types/mcp/discoverable-tool-metadata.d.ts +0 -7
  184. package/dist/types/tools/vim.d.ts +0 -58
  185. package/dist/types/vim/buffer.d.ts +0 -41
  186. package/dist/types/vim/commands.d.ts +0 -6
  187. package/dist/types/vim/engine.d.ts +0 -47
  188. package/dist/types/vim/parser.d.ts +0 -3
  189. package/dist/types/vim/render.d.ts +0 -25
  190. package/dist/types/vim/types.d.ts +0 -182
  191. package/src/hashline/parser.ts +0 -212
  192. package/src/mcp/discoverable-tool-metadata.ts +0 -24
  193. package/src/prompts/tools/vim.md +0 -98
  194. package/src/tools/vim.ts +0 -949
  195. package/src/vim/buffer.ts +0 -309
  196. package/src/vim/commands.ts +0 -382
  197. package/src/vim/engine.ts +0 -2409
  198. package/src/vim/parser.ts +0 -134
  199. package/src/vim/render.ts +0 -252
  200. package/src/vim/types.ts +0 -197
@@ -1,58 +0,0 @@
1
- import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback } from "@oh-my-pi/pi-agent-core";
2
- import type { Component } from "@oh-my-pi/pi-tui";
3
- import * as z from "zod/v4";
4
- import type { RenderResultOptions } from "../extensibility/custom-tools/types";
5
- import { type Theme } from "../modes/theme/theme";
6
- import type { VimToolDetails } from "../vim/types";
7
- import type { ToolSession } from ".";
8
- declare const vimSchema: z.ZodObject<{
9
- file: z.ZodString;
10
- steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
- kbd: z.ZodArray<z.ZodString>;
12
- insert: z.ZodOptional<z.ZodString>;
13
- }, z.core.$strip>>>;
14
- pause: z.ZodOptional<z.ZodBoolean>;
15
- }, z.core.$strip>;
16
- type VimParams = z.infer<typeof vimSchema>;
17
- interface VimRenderStep {
18
- kbd?: string[];
19
- insert?: string;
20
- }
21
- export interface VimRenderArgs {
22
- file?: string;
23
- steps?: VimRenderStep[];
24
- pause?: boolean;
25
- __partialJson?: string;
26
- }
27
- export declare class VimTool implements AgentTool<typeof vimSchema, VimToolDetails> {
28
- #private;
29
- private readonly session;
30
- readonly name = "vim";
31
- readonly label = "Vim";
32
- readonly description: string;
33
- readonly parameters: z.ZodObject<{
34
- file: z.ZodString;
35
- steps: z.ZodOptional<z.ZodArray<z.ZodObject<{
36
- kbd: z.ZodArray<z.ZodString>;
37
- insert: z.ZodOptional<z.ZodString>;
38
- }, z.core.$strip>>>;
39
- pause: z.ZodOptional<z.ZodBoolean>;
40
- }, z.core.$strip>;
41
- readonly concurrency = "exclusive";
42
- constructor(session: ToolSession);
43
- execute(_toolCallId: string, params: VimParams, signal?: AbortSignal, onUpdate?: AgentToolUpdateCallback<VimToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<VimToolDetails>>;
44
- }
45
- export declare function resetVimRendererStateForTest(): void;
46
- export declare const vimToolRenderer: {
47
- renderCall(args: VimRenderArgs, options: RenderResultOptions, uiTheme: Theme): Component;
48
- renderResult(result: {
49
- content: Array<{
50
- type: string;
51
- text?: string;
52
- }>;
53
- details?: VimToolDetails;
54
- isError?: boolean;
55
- }, options: RenderResultOptions, uiTheme: Theme): Component;
56
- mergeCallAndResult: boolean;
57
- };
58
- export { vimSchema };
@@ -1,41 +0,0 @@
1
- import { type Position, type VimBufferSnapshot, type VimFingerprint, type VimLoadedFile } from "./types";
2
- export declare function snapshotEqual(left: VimBufferSnapshot, right: VimBufferSnapshot): boolean;
3
- export declare class VimBuffer {
4
- displayPath: string;
5
- filePath: string;
6
- lines: string[];
7
- cursor: Position;
8
- modified: boolean;
9
- trailingNewline: boolean;
10
- baseFingerprint: VimFingerprint | null;
11
- editabilityChecked: boolean;
12
- constructor(input: VimLoadedFile);
13
- clone(): VimBuffer;
14
- createSnapshot(): VimBufferSnapshot;
15
- restore(snapshot: VimBufferSnapshot): void;
16
- replaceLoadedFile(input: VimLoadedFile): void;
17
- markSaved(input: VimLoadedFile): void;
18
- lineCount(): number;
19
- lastLineIndex(): number;
20
- getLine(line: number): string;
21
- clampLine(line: number): number;
22
- clampCol(line: number, col: number): number;
23
- setCursor(position: Position): void;
24
- clampCursor(): void;
25
- firstNonBlank(line: number): number;
26
- getText(): string;
27
- setText(text: string, trailingNewline?: boolean): void;
28
- currentOffset(): number;
29
- positionToOffset(position: Position): number;
30
- offsetToPosition(offset: number): Position;
31
- setCursorFromOffset(offset: number): void;
32
- replaceOffsets(start: number, end: number, replacement: string, cursorOffset?: number): void;
33
- deleteOffsets(start: number, end: number): string;
34
- deleteLines(startLine: number, endLine: number): string[];
35
- insertLines(index: number, newLines: string[]): void;
36
- replaceLine(line: number, content: string): void;
37
- joinLines(startLine: number, count: number): void;
38
- indentLines(startLine: number, endLine: number, indentUnit: string, direction: 1 | -1): void;
39
- getCharacterAtOffset(offset: number): string;
40
- getCharacter(position: Position): string;
41
- }
@@ -1,6 +0,0 @@
1
- import type { VimExCommand } from "./types";
2
- export interface VimExParseContext {
3
- currentLine: number;
4
- lastLine: number;
5
- }
6
- export declare function parseExCommand(input: string, context?: VimExParseContext): VimExCommand;
@@ -1,47 +0,0 @@
1
- import type { FileDiagnosticsResult } from "../lsp";
2
- import { type VimBuffer } from "./buffer";
3
- import type { Position, VimInputMode, VimKeyToken, VimLoadedFile, VimPendingInput, VimRegister, VimSearchState, VimSelection } from "./types";
4
- export interface VimSaveResult {
5
- loaded: VimLoadedFile;
6
- diagnostics?: FileDiagnosticsResult;
7
- }
8
- export interface VimEngineCallbacks {
9
- beforeMutate: (buffer: VimBuffer) => Promise<void>;
10
- loadBuffer: (path: string) => Promise<VimLoadedFile>;
11
- saveBuffer: (buffer: VimBuffer, options?: {
12
- force?: boolean;
13
- }) => Promise<VimSaveResult>;
14
- }
15
- export declare class VimEngine {
16
- #private;
17
- buffer: VimBuffer;
18
- inputMode: VimInputMode;
19
- selectionAnchor: Position | null;
20
- register: VimRegister;
21
- lastSearch: VimSearchState | null;
22
- lastCharFind: {
23
- char: string;
24
- mode: "f" | "F" | "t" | "T";
25
- } | null;
26
- lastVisual: {
27
- anchor: Position;
28
- cursor: Position;
29
- mode: VimInputMode;
30
- } | null;
31
- lastCommand?: string;
32
- statusMessage?: string;
33
- diagnostics?: FileDiagnosticsResult;
34
- viewportStart: number;
35
- closed: boolean;
36
- constructor(buffer: VimBuffer, callbacks: VimEngineCallbacks);
37
- clone(callbacks?: Partial<VimEngineCallbacks>): VimEngine;
38
- getPublicMode(): import("./types").VimMode;
39
- getSelection(): VimSelection | undefined;
40
- getPendingInput(): VimPendingInput | undefined;
41
- rollbackPendingInsert(): void;
42
- setCursor(line: number, col: number): void;
43
- executeTokens(tokens: readonly VimKeyToken[], lastCommand?: string, onStep?: () => Promise<void>): Promise<void>;
44
- close(force: boolean): Promise<void>;
45
- centerViewportOnCursor(size?: number): void;
46
- applyLiteralInsert(text: string, exitInsertMode: boolean): Promise<void>;
47
- }
@@ -1,3 +0,0 @@
1
- import { type VimKeyToken } from "./types";
2
- export declare function parseKeySequences(sequences: string[]): VimKeyToken[];
3
- export declare function replayTokens(values: readonly string[]): VimKeyToken[];
@@ -1,25 +0,0 @@
1
- import type { VimErrorLocation, VimMode, VimPendingInput, VimSelection, VimToolDetails, VimViewport } from "./types";
2
- export declare const VIM_OPEN_VIEWPORT_LINES = 80;
3
- export declare const VIM_DEFAULT_VIEWPORT_LINES = 10;
4
- interface ViewportRenderInput {
5
- file: string;
6
- mode: VimMode;
7
- cursor: {
8
- line: number;
9
- col: number;
10
- };
11
- totalLines: number;
12
- modified: boolean;
13
- lines: string[];
14
- viewport: VimViewport;
15
- selection?: VimSelection;
16
- statusMessage?: string;
17
- lastCommand?: string;
18
- pendingInput?: VimPendingInput;
19
- errorLocation?: VimErrorLocation;
20
- closed?: boolean;
21
- }
22
- export declare function computeViewport(cursorLine: number, totalLines: number, size: number, preferredStart?: number): VimViewport;
23
- export declare function renderVimDetails(details: VimToolDetails): string;
24
- export declare function buildDetails(input: ViewportRenderInput): VimToolDetails;
25
- export {};
@@ -1,182 +0,0 @@
1
- import type { FileDiagnosticsResult } from "../lsp";
2
- import type { OutputMeta } from "../tools/output-meta";
3
- export type VimMode = "NORMAL" | "INSERT" | "VISUAL" | "VISUAL-LINE" | "COMMAND";
4
- export type VimInputMode = "normal" | "insert" | "visual" | "visual-line" | "command" | "search-forward" | "search-backward";
5
- export interface Position {
6
- line: number;
7
- col: number;
8
- }
9
- export interface VimViewport {
10
- start: number;
11
- end: number;
12
- }
13
- export interface VimSelection {
14
- kind: "char" | "line";
15
- start: Position;
16
- end: Position;
17
- }
18
- export interface VimFocusLine {
19
- line: number;
20
- text: string;
21
- windowStartCol: number;
22
- windowEndCol: number;
23
- caretCol: number;
24
- }
25
- export interface VimViewportLine {
26
- line: number;
27
- text: string;
28
- isCursor: boolean;
29
- isSelected: boolean;
30
- cursorCol?: number;
31
- }
32
- export interface VimPendingInput {
33
- kind: "insert" | "command" | "search-forward" | "search-backward";
34
- text: string;
35
- }
36
- export interface VimErrorLocation {
37
- sequenceIndex: number;
38
- offset: number;
39
- }
40
- export interface VimToolDetails {
41
- file: string;
42
- mode: VimMode;
43
- cursor: {
44
- line: number;
45
- col: number;
46
- };
47
- totalLines: number;
48
- modified: boolean;
49
- viewport: VimViewport;
50
- focus?: VimFocusLine;
51
- viewportLines?: VimViewportLine[];
52
- selection?: VimSelection;
53
- pendingInput?: VimPendingInput;
54
- errorLocation?: VimErrorLocation;
55
- closed?: boolean;
56
- meta?: OutputMeta;
57
- lastCommand?: string;
58
- statusMessage?: string;
59
- diagnostics?: FileDiagnosticsResult;
60
- }
61
- export interface VimFingerprint {
62
- exists: boolean;
63
- size: number;
64
- mtimeMs: number;
65
- hash: string;
66
- }
67
- export interface VimLoadedFile {
68
- absolutePath: string;
69
- displayPath: string;
70
- lines: string[];
71
- trailingNewline: boolean;
72
- fingerprint: VimFingerprint | null;
73
- }
74
- export interface VimKeyToken {
75
- value: string;
76
- display: string;
77
- sequenceIndex: number;
78
- offset: number;
79
- }
80
- export interface VimRegister {
81
- kind: "char" | "line";
82
- text: string;
83
- }
84
- export interface VimSearchState {
85
- pattern: string;
86
- direction: 1 | -1;
87
- }
88
- export interface VimBufferSnapshot {
89
- displayPath: string;
90
- filePath: string;
91
- lines: string[];
92
- cursor: Position;
93
- modified: boolean;
94
- trailingNewline: boolean;
95
- baseFingerprint: VimFingerprint | null;
96
- editabilityChecked: boolean;
97
- }
98
- export interface VimUndoEntry {
99
- before: VimBufferSnapshot;
100
- after: VimBufferSnapshot;
101
- }
102
- export interface VimLineRange {
103
- start: number;
104
- end: number;
105
- }
106
- export type VimExCommand = {
107
- kind: "write";
108
- force: boolean;
109
- } | {
110
- kind: "update";
111
- force: boolean;
112
- } | {
113
- kind: "quit";
114
- force: boolean;
115
- } | {
116
- kind: "write-quit";
117
- force: boolean;
118
- } | {
119
- kind: "edit";
120
- force: boolean;
121
- path?: string;
122
- } | {
123
- kind: "goto-line";
124
- line: number;
125
- } | {
126
- kind: "substitute";
127
- range?: VimLineRange | "all";
128
- pattern: string;
129
- replacement: string;
130
- flags: string;
131
- } | {
132
- kind: "delete";
133
- range?: VimLineRange | "all";
134
- } | {
135
- kind: "yank";
136
- range?: VimLineRange | "all";
137
- } | {
138
- kind: "put";
139
- range?: VimLineRange | "all";
140
- before: boolean;
141
- } | {
142
- kind: "copy";
143
- range?: VimLineRange | "all";
144
- destination: number;
145
- } | {
146
- kind: "move";
147
- range?: VimLineRange | "all";
148
- destination: number;
149
- } | {
150
- kind: "sort";
151
- range?: VimLineRange | "all";
152
- flags: string;
153
- } | {
154
- kind: "join";
155
- range?: VimLineRange | "all";
156
- trimWhitespace: boolean;
157
- } | {
158
- kind: "global";
159
- range?: VimLineRange | "all";
160
- pattern: string;
161
- command: string;
162
- invert: boolean;
163
- } | {
164
- kind: "append";
165
- range?: VimLineRange;
166
- text: string;
167
- } | {
168
- kind: "insert-before";
169
- range?: VimLineRange;
170
- text: string;
171
- };
172
- export declare class VimInputError extends Error {
173
- location?: {
174
- sequenceIndex: number;
175
- offset: number;
176
- };
177
- constructor(message: string, token?: VimKeyToken);
178
- }
179
- export declare function clonePosition(position: Position): Position;
180
- export declare function minPosition(left: Position, right: Position): Position;
181
- export declare function maxPosition(left: Position, right: Position): Position;
182
- export declare function toPublicMode(mode: VimInputMode): VimMode;
@@ -1,212 +0,0 @@
1
- import { ABORT_MARKER, ABORT_WARNING, BEGIN_PATCH_MARKER, END_PATCH_MARKER, RANGE_INTERIOR_HASH } from "./constants";
2
- import {
3
- describeAnchorExamples,
4
- HL_FILE_PREFIX,
5
- HL_HASH_CAPTURE_RE_RAW,
6
- HL_OP_CHARS,
7
- HL_OP_INSERT_AFTER,
8
- HL_OP_INSERT_BEFORE,
9
- HL_OP_REPLACE,
10
- } from "./hash";
11
- import type { Anchor, HashlineCursor, HashlineEdit } from "./types";
12
-
13
- // Leniently accept anchors copied from read/search output:
14
- // - optional leading line-marker decoration (`*`, `>`, `+`, `-`)
15
- // - the required `LINE+HASH`
16
- // - an optional trailing `|TEXT` body (or anything after the hash) so users
17
- // can paste a full `LINE+HASH|TEXT` line verbatim.
18
- const LID_CAPTURE_RE = new RegExp(`^\\s*[>+\\-*]*\\s*${HL_HASH_CAPTURE_RE_RAW}(?:\\|.*)?\\s*$`);
19
- const regexEscape = (str: string): string => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
20
-
21
- function parseLid(raw: string, lineNum: number): Anchor {
22
- const match = LID_CAPTURE_RE.exec(raw);
23
- if (!match) {
24
- throw new Error(
25
- `line ${lineNum}: expected a full anchor such as ${describeAnchorExamples("119")}; ` +
26
- `got ${JSON.stringify(raw)}.`,
27
- );
28
- }
29
- return { line: Number.parseInt(match[1], 10), hash: match[2] };
30
- }
31
-
32
- interface ParsedRange {
33
- start: Anchor;
34
- end: Anchor;
35
- }
36
-
37
- function parseRange(raw: string, lineNum: number): ParsedRange {
38
- if (!raw.includes("..")) {
39
- const start = parseLid(raw, lineNum);
40
- return { start, end: { ...start } };
41
- }
42
- const [startRaw, endRaw, extra] = raw.split("..");
43
- if (extra !== undefined || !startRaw || !endRaw) {
44
- throw new Error(
45
- `line ${lineNum}: range must include exactly two full anchors separated by "..". ` +
46
- `For a one-line edit, repeat the same anchor on both sides.`,
47
- );
48
- }
49
- const start = parseLid(startRaw, lineNum);
50
- const end = parseLid(endRaw, lineNum);
51
- if (end.line < start.line) {
52
- throw new Error(`line ${lineNum}: range ${startRaw}..${endRaw} ends before it starts.`);
53
- }
54
- if (end.line === start.line && end.hash !== start.hash) {
55
- throw new Error(`line ${lineNum}: range ${startRaw}..${endRaw} uses two different hashes for the same line.`);
56
- }
57
- return { start, end };
58
- }
59
-
60
- function expandRange(range: ParsedRange): Anchor[] {
61
- const anchors: Anchor[] = [];
62
- for (let line = range.start.line; line <= range.end.line; line++) {
63
- const hash =
64
- line === range.start.line ? range.start.hash : line === range.end.line ? range.end.hash : RANGE_INTERIOR_HASH;
65
- anchors.push({ line, hash });
66
- }
67
- return anchors;
68
- }
69
-
70
- function parseInsertTarget(raw: string, lineNum: number, kind: "before" | "after"): HashlineCursor {
71
- if (raw === "BOF") return { kind: "bof" };
72
- if (raw === "EOF") return { kind: "eof" };
73
- const cursorKind = kind === "before" ? "before_anchor" : "after_anchor";
74
- return { kind: cursorKind, anchor: parseLid(raw, lineNum) };
75
- }
76
-
77
- const INSERT_BEFORE_OP_RE = new RegExp(`^${regexEscape(HL_OP_INSERT_BEFORE)}\\s*(\\S+)\\s*$`);
78
- const INSERT_AFTER_OP_RE = new RegExp(`^${regexEscape(HL_OP_INSERT_AFTER)}\\s*(\\S+)\\s*$`);
79
- const REPLACE_OP_RE = new RegExp(`^${regexEscape(HL_OP_REPLACE)}\\s*([^\\s+<\\-=]\\S*)\\s*$`);
80
-
81
- function isEnvelopeOrAbortMarkerLine(line: string): boolean {
82
- const trimmed = line.trimEnd();
83
- return trimmed === BEGIN_PATCH_MARKER || trimmed === END_PATCH_MARKER || trimmed === ABORT_MARKER;
84
- }
85
-
86
- function isPayloadTerminatorLine(line: string): boolean {
87
- const first = line[0];
88
- return (
89
- first === HL_FILE_PREFIX ||
90
- (first !== undefined && HL_OP_CHARS.includes(first)) ||
91
- isEnvelopeOrAbortMarkerLine(line)
92
- );
93
- }
94
-
95
- export function cloneCursor(cursor: HashlineCursor): HashlineCursor {
96
- if (cursor.kind === "before_anchor") return { kind: "before_anchor", anchor: { ...cursor.anchor } };
97
- if (cursor.kind === "after_anchor") return { kind: "after_anchor", anchor: { ...cursor.anchor } };
98
- return cursor;
99
- }
100
-
101
- function collectPayload(
102
- lines: string[],
103
- startIndex: number,
104
- opLineNum: number,
105
- requirePayload: boolean,
106
- ): { payload: string[]; nextIndex: number } {
107
- const payload: string[] = [];
108
- let index = startIndex;
109
- while (index < lines.length) {
110
- const line = lines[index];
111
- if (isPayloadTerminatorLine(line)) break;
112
- payload.push(line);
113
- index++;
114
- }
115
- if (payload.length === 0 && requirePayload) {
116
- throw new Error(
117
- `line ${opLineNum}: ${HL_OP_INSERT_BEFORE} and ${HL_OP_INSERT_AFTER} operations require at least one verbatim payload line.`,
118
- );
119
- }
120
- return { payload, nextIndex: index };
121
- }
122
-
123
- export function parseHashline(diff: string): HashlineEdit[] {
124
- return parseHashlineWithWarnings(diff).edits;
125
- }
126
-
127
- export function parseHashlineWithWarnings(diff: string): { edits: HashlineEdit[]; warnings: string[] } {
128
- const edits: HashlineEdit[] = [];
129
- const warnings: string[] = [];
130
- const lines = diff.split(/\r?\n/);
131
- if (diff.endsWith("\n") && lines.at(-1) === "") lines.pop();
132
- let editIndex = 0;
133
-
134
- const pushInsert = (cursor: HashlineCursor, text: string, lineNum: number) => {
135
- edits.push({ kind: "insert", cursor: cloneCursor(cursor), text, lineNum, index: editIndex++ });
136
- };
137
-
138
- for (let i = 0; i < lines.length; ) {
139
- const lineNum = i + 1;
140
- const line = lines[i];
141
-
142
- if (line.trim().length === 0) {
143
- i++;
144
- continue;
145
- }
146
- if (line === END_PATCH_MARKER) {
147
- break;
148
- }
149
- if (line === ABORT_MARKER) {
150
- warnings.push(ABORT_WARNING);
151
- break;
152
- }
153
- if (line === BEGIN_PATCH_MARKER) {
154
- i++;
155
- continue;
156
- }
157
-
158
- const insertBeforeMatch = INSERT_BEFORE_OP_RE.exec(line);
159
- if (insertBeforeMatch) {
160
- const cursor = parseInsertTarget(insertBeforeMatch[1], lineNum, "before");
161
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, true);
162
- for (const text of payload) pushInsert(cursor, text, lineNum);
163
- i = nextIndex;
164
- continue;
165
- }
166
-
167
- const insertAfterMatch = INSERT_AFTER_OP_RE.exec(line);
168
- if (insertAfterMatch) {
169
- const cursor = parseInsertTarget(insertAfterMatch[1], lineNum, "after");
170
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, true);
171
- for (const text of payload) pushInsert(cursor, text, lineNum);
172
- i = nextIndex;
173
- continue;
174
- }
175
-
176
- const replaceMatch = REPLACE_OP_RE.exec(line);
177
- if (replaceMatch) {
178
- const range = parseRange(replaceMatch[1], lineNum);
179
- const { payload, nextIndex } = collectPayload(lines, i + 1, lineNum, false);
180
- if (payload.length > 0) {
181
- for (const text of payload) {
182
- edits.push({
183
- kind: "insert",
184
- cursor: { kind: "before_anchor", anchor: { ...range.start } },
185
- text,
186
- lineNum,
187
- index: editIndex++,
188
- });
189
- }
190
- }
191
- for (const anchor of expandRange(range)) {
192
- edits.push({ kind: "delete", anchor, lineNum, index: editIndex++ });
193
- }
194
- i = nextIndex;
195
- continue;
196
- }
197
-
198
- if (isPayloadTerminatorLine(line) || /^[-@\u00B6]/u.test(line)) {
199
- throw new Error(
200
- `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). ` +
201
- `Got ${JSON.stringify(line)}.`,
202
- );
203
- }
204
-
205
- throw new Error(
206
- `line ${lineNum}: payload line has no preceding ${HL_OP_INSERT_BEFORE}, ${HL_OP_INSERT_AFTER}, or ${HL_OP_REPLACE} operation. ` +
207
- `Got ${JSON.stringify(line)}.`,
208
- );
209
- }
210
-
211
- return { edits, warnings };
212
- }
@@ -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";