@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.
- package/CHANGELOG.md +110 -0
- package/dist/types/cli/file-processor.d.ts +1 -1
- package/dist/types/config/settings-schema.d.ts +45 -3
- package/dist/types/config/settings.d.ts +1 -1
- package/dist/types/debug/raw-sse.d.ts +2 -0
- package/dist/types/edit/file-read-cache.d.ts +15 -4
- package/dist/types/edit/index.d.ts +3 -8
- package/dist/types/edit/renderer.d.ts +1 -2
- package/dist/types/eval/__tests__/shared-executors.test.d.ts +1 -0
- package/dist/types/eval/js/shared/local-module-loader.d.ts +16 -0
- package/dist/types/eval/js/shared/rewrite-imports.d.ts +4 -0
- package/dist/types/eval/js/shared/runtime.d.ts +14 -8
- package/dist/types/eval/py/executor.d.ts +1 -2
- package/dist/types/eval/py/kernel.d.ts +6 -0
- package/dist/types/eval/py/tool-bridge.d.ts +1 -5
- package/dist/types/eval/session-id.d.ts +3 -0
- package/dist/types/extensibility/extensions/types.d.ts +1 -3
- package/dist/types/hashline/anchors.d.ts +15 -9
- package/dist/types/hashline/constants.d.ts +0 -2
- package/dist/types/hashline/diff.d.ts +1 -2
- package/dist/types/hashline/executor.d.ts +52 -0
- package/dist/types/hashline/hash.d.ts +44 -93
- package/dist/types/hashline/index.d.ts +2 -1
- package/dist/types/hashline/input.d.ts +2 -9
- package/dist/types/hashline/recovery.d.ts +3 -9
- package/dist/types/hashline/tokenizer.d.ts +91 -0
- package/dist/types/hashline/types.d.ts +5 -7
- package/dist/types/modes/components/extensions/types.d.ts +0 -4
- package/dist/types/modes/types.d.ts +1 -0
- package/dist/types/modes/utils/ui-helpers.d.ts +1 -0
- package/dist/types/sdk.d.ts +2 -0
- package/dist/types/session/agent-session.d.ts +11 -15
- package/dist/types/session/agent-storage.d.ts +11 -10
- package/dist/types/slash-commands/acp-builtins.d.ts +3 -3
- package/dist/types/slash-commands/types.d.ts +0 -5
- package/dist/types/task/executor.d.ts +2 -0
- package/dist/types/tool-discovery/tool-index.d.ts +0 -50
- package/dist/types/tools/index.d.ts +2 -8
- package/dist/types/tools/match-line-format.d.ts +4 -4
- package/dist/types/tools/output-schema-validator.d.ts +64 -0
- package/dist/types/tools/review.d.ts +13 -0
- package/dist/types/tools/search-tool-bm25.d.ts +1 -1
- package/dist/types/tools/search.d.ts +4 -3
- package/dist/types/utils/edit-mode.d.ts +1 -1
- package/dist/types/web/kagi.d.ts +4 -2
- package/dist/types/web/parallel.d.ts +4 -3
- package/dist/types/web/scrapers/types.d.ts +2 -1
- package/dist/types/web/search/index.d.ts +12 -4
- package/dist/types/web/search/provider.d.ts +2 -1
- package/dist/types/web/search/providers/anthropic.d.ts +9 -4
- package/dist/types/web/search/providers/base.d.ts +34 -2
- package/dist/types/web/search/providers/brave.d.ts +8 -1
- package/dist/types/web/search/providers/codex.d.ts +13 -9
- package/dist/types/web/search/providers/exa.d.ts +10 -1
- package/dist/types/web/search/providers/gemini.d.ts +20 -23
- package/dist/types/web/search/providers/jina.d.ts +2 -1
- package/dist/types/web/search/providers/kagi.d.ts +4 -1
- package/dist/types/web/search/providers/kimi.d.ts +10 -1
- package/dist/types/web/search/providers/parallel.d.ts +3 -2
- package/dist/types/web/search/providers/perplexity.d.ts +5 -2
- package/dist/types/web/search/providers/searxng.d.ts +2 -1
- package/dist/types/web/search/providers/synthetic.d.ts +5 -8
- package/dist/types/web/search/providers/tavily.d.ts +11 -4
- package/dist/types/web/search/providers/utils.d.ts +8 -6
- package/dist/types/web/search/providers/zai.d.ts +12 -3
- package/package.json +7 -7
- package/src/cli/file-processor.ts +12 -2
- package/src/cli.ts +0 -8
- package/src/commands/commit.ts +8 -8
- package/src/config/prompt-templates.ts +6 -6
- package/src/config/settings-schema.ts +47 -3
- package/src/config/settings.ts +5 -5
- package/src/debug/raw-sse.ts +68 -3
- package/src/edit/file-read-cache.ts +68 -25
- package/src/edit/index.ts +6 -37
- package/src/edit/renderer.ts +9 -47
- package/src/edit/streaming.ts +43 -56
- package/src/eval/__tests__/shared-executors.test.ts +520 -0
- package/src/eval/js/context-manager.ts +64 -53
- package/src/eval/js/shared/local-module-loader.ts +265 -0
- package/src/eval/js/shared/prelude.txt +4 -0
- package/src/eval/js/shared/rewrite-imports.ts +85 -0
- package/src/eval/js/shared/runtime.ts +129 -86
- package/src/eval/js/worker-core.ts +23 -38
- package/src/eval/py/executor.ts +155 -84
- package/src/eval/py/kernel.ts +10 -1
- package/src/eval/py/prelude.py +22 -24
- package/src/eval/py/runner.py +203 -85
- package/src/eval/py/tool-bridge.ts +17 -10
- package/src/eval/session-id.ts +8 -0
- package/src/exec/bash-executor.ts +27 -16
- package/src/extensibility/extensions/runner.ts +0 -1
- package/src/extensibility/extensions/types.ts +1 -3
- package/src/hashline/anchors.ts +56 -65
- package/src/hashline/apply.ts +29 -31
- package/src/hashline/constants.ts +0 -3
- package/src/hashline/diff-preview.ts +4 -5
- package/src/hashline/diff.ts +30 -4
- package/src/hashline/execute.ts +91 -26
- package/src/hashline/executor.ts +239 -0
- package/src/hashline/grammar.lark +12 -10
- package/src/hashline/hash.ts +69 -114
- package/src/hashline/index.ts +2 -1
- package/src/hashline/input.ts +48 -41
- package/src/hashline/prefixes.ts +21 -11
- package/src/hashline/recovery.ts +63 -71
- package/src/hashline/stream.ts +2 -2
- package/src/hashline/tokenizer.ts +467 -0
- package/src/hashline/types.ts +6 -8
- package/src/internal-urls/docs-index.generated.ts +7 -7
- package/src/modes/components/extensions/types.ts +0 -5
- package/src/modes/components/session-observer-overlay.ts +11 -2
- package/src/modes/components/settings-selector.ts +10 -1
- package/src/modes/components/tree-selector.ts +10 -2
- package/src/modes/controllers/command-controller.ts +1 -3
- package/src/modes/controllers/extension-ui-controller.ts +10 -11
- package/src/modes/controllers/selector-controller.ts +5 -5
- package/src/modes/theme/theme.ts +4 -2
- package/src/modes/types.ts +4 -1
- package/src/modes/utils/ui-helpers.ts +4 -0
- package/src/prompts/agents/explore.md +1 -1
- package/src/prompts/tools/ast-edit.md +1 -1
- package/src/prompts/tools/ast-grep.md +1 -1
- package/src/prompts/tools/eval.md +1 -1
- package/src/prompts/tools/hashline.md +73 -94
- package/src/prompts/tools/read.md +4 -4
- package/src/prompts/tools/search.md +3 -3
- package/src/sdk.ts +33 -26
- package/src/session/agent-session.ts +59 -66
- package/src/session/agent-storage.ts +13 -14
- package/src/slash-commands/acp-builtins.ts +3 -3
- package/src/slash-commands/types.ts +0 -6
- package/src/task/executor.ts +26 -57
- package/src/task/index.ts +8 -4
- package/src/tool-discovery/tool-index.ts +0 -134
- package/src/tools/ast-edit.ts +36 -13
- package/src/tools/ast-grep.ts +45 -4
- package/src/tools/browser/tab-worker.ts +3 -2
- package/src/tools/eval.ts +2 -1
- package/src/tools/fetch.ts +23 -14
- package/src/tools/index.ts +2 -8
- package/src/tools/irc.ts +59 -5
- package/src/tools/match-line-format.ts +5 -7
- package/src/tools/output-schema-validator.ts +132 -0
- package/src/tools/read.ts +142 -31
- package/src/tools/review.ts +23 -0
- package/src/tools/search-tool-bm25.ts +3 -30
- package/src/tools/search.ts +48 -16
- package/src/tools/write.ts +3 -3
- package/src/tools/yield.ts +32 -41
- package/src/utils/edit-mode.ts +1 -2
- package/src/utils/file-mentions.ts +2 -2
- package/src/web/kagi.ts +15 -6
- package/src/web/parallel.ts +9 -6
- package/src/web/scrapers/types.ts +7 -1
- package/src/web/scrapers/youtube.ts +13 -7
- package/src/web/search/index.ts +37 -11
- package/src/web/search/provider.ts +5 -3
- package/src/web/search/providers/anthropic.ts +30 -21
- package/src/web/search/providers/base.ts +35 -2
- package/src/web/search/providers/brave.ts +4 -4
- package/src/web/search/providers/codex.ts +118 -89
- package/src/web/search/providers/exa.ts +3 -2
- package/src/web/search/providers/gemini.ts +58 -155
- package/src/web/search/providers/jina.ts +4 -4
- package/src/web/search/providers/kagi.ts +17 -11
- package/src/web/search/providers/kimi.ts +29 -13
- package/src/web/search/providers/parallel.ts +171 -23
- package/src/web/search/providers/perplexity.ts +38 -37
- package/src/web/search/providers/searxng.ts +3 -1
- package/src/web/search/providers/synthetic.ts +16 -19
- package/src/web/search/providers/tavily.ts +23 -18
- package/src/web/search/providers/utils.ts +11 -17
- package/src/web/search/providers/zai.ts +16 -8
- package/dist/types/hashline/parser.d.ts +0 -7
- package/dist/types/mcp/discoverable-tool-metadata.d.ts +0 -7
- package/dist/types/tools/vim.d.ts +0 -58
- package/dist/types/vim/buffer.d.ts +0 -41
- package/dist/types/vim/commands.d.ts +0 -6
- package/dist/types/vim/engine.d.ts +0 -47
- package/dist/types/vim/parser.d.ts +0 -3
- package/dist/types/vim/render.d.ts +0 -25
- package/dist/types/vim/types.d.ts +0 -182
- package/src/hashline/parser.ts +0 -246
- package/src/mcp/discoverable-tool-metadata.ts +0 -24
- package/src/prompts/tools/vim.md +0 -98
- package/src/tools/vim.ts +0 -949
- package/src/vim/buffer.ts +0 -309
- package/src/vim/commands.ts +0 -382
- package/src/vim/engine.ts +0 -2409
- package/src/vim/parser.ts +0 -134
- package/src/vim/render.ts +0 -252
- package/src/vim/types.ts +0 -197
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
* Uses Tavily's agent-focused search API to return structured results with an
|
|
5
5
|
* optional synthesized answer.
|
|
6
6
|
*/
|
|
7
|
-
import { getEnvApiKey } from "@oh-my-pi/pi-ai";
|
|
7
|
+
import { type AuthStorage, getEnvApiKey } from "@oh-my-pi/pi-ai";
|
|
8
8
|
import type { SearchResponse, SearchSource } from "../../../web/search/types";
|
|
9
9
|
import { SearchProviderError } from "../../../web/search/types";
|
|
10
10
|
import { clampNumResults, dateToAgeSeconds } from "../utils";
|
|
11
11
|
import type { SearchParams } from "./base";
|
|
12
12
|
import { SearchProvider } from "./base";
|
|
13
|
-
import { classifyProviderHttpError,
|
|
13
|
+
import { classifyProviderHttpError, withHardTimeout } from "./utils";
|
|
14
14
|
|
|
15
15
|
const TAVILY_SEARCH_URL = "https://api.tavily.com/search";
|
|
16
16
|
const DEFAULT_NUM_RESULTS = 5;
|
|
@@ -58,9 +58,13 @@ function getErrorMessage(value: unknown): string | null {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/** Find Tavily API key
|
|
62
|
-
export async function findApiKey(
|
|
63
|
-
|
|
61
|
+
/** Find Tavily API key through AuthStorage's unified refresh pipeline. */
|
|
62
|
+
export async function findApiKey(
|
|
63
|
+
authStorage: AuthStorage,
|
|
64
|
+
sessionId: string | undefined,
|
|
65
|
+
signal: AbortSignal | undefined,
|
|
66
|
+
): Promise<string | null> {
|
|
67
|
+
return (await authStorage.getApiKey("tavily", sessionId, { signal })) ?? null;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
/** Exported for testing. Builds the Tavily request body from unified params. */
|
|
@@ -116,16 +120,22 @@ async function callTavilySearch(apiKey: string, params: TavilySearchParams): Pro
|
|
|
116
120
|
}
|
|
117
121
|
|
|
118
122
|
/** Execute Tavily web search. */
|
|
119
|
-
export async function searchTavily(params:
|
|
120
|
-
const
|
|
123
|
+
export async function searchTavily(params: SearchParams): Promise<SearchResponse> {
|
|
124
|
+
const tavilyParams: TavilySearchParams = {
|
|
125
|
+
query: params.query,
|
|
126
|
+
num_results: params.numSearchResults ?? params.limit,
|
|
127
|
+
recency: params.recency,
|
|
128
|
+
signal: params.signal,
|
|
129
|
+
};
|
|
130
|
+
const apiKey = await findApiKey(params.authStorage, params.sessionId, params.signal);
|
|
121
131
|
if (!apiKey) {
|
|
122
132
|
throw new Error(
|
|
123
|
-
'Tavily credentials not found. Set TAVILY_API_KEY or
|
|
133
|
+
'Tavily credentials not found. Set TAVILY_API_KEY or configure an API key for provider "tavily".',
|
|
124
134
|
);
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
const numResults = clampNumResults(
|
|
128
|
-
const response = await callTavilySearch(apiKey,
|
|
137
|
+
const numResults = clampNumResults(tavilyParams.num_results, DEFAULT_NUM_RESULTS, MAX_NUM_RESULTS);
|
|
138
|
+
const response = await callTavilySearch(apiKey, tavilyParams);
|
|
129
139
|
const sources: SearchSource[] = [];
|
|
130
140
|
|
|
131
141
|
for (const result of response.results ?? []) {
|
|
@@ -153,16 +163,11 @@ export class TavilyProvider extends SearchProvider {
|
|
|
153
163
|
readonly id = "tavily";
|
|
154
164
|
readonly label = "Tavily";
|
|
155
165
|
|
|
156
|
-
isAvailable():
|
|
157
|
-
return
|
|
166
|
+
isAvailable(authStorage: AuthStorage): boolean {
|
|
167
|
+
return authStorage.hasAuth("tavily") || !!getEnvApiKey("tavily");
|
|
158
168
|
}
|
|
159
169
|
|
|
160
170
|
search(params: SearchParams): Promise<SearchResponse> {
|
|
161
|
-
return searchTavily(
|
|
162
|
-
query: params.query,
|
|
163
|
-
num_results: params.numSearchResults ?? params.limit,
|
|
164
|
-
recency: params.recency,
|
|
165
|
-
signal: params.signal,
|
|
166
|
-
});
|
|
171
|
+
return searchTavily(params);
|
|
167
172
|
}
|
|
168
173
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AgentStorage } from "../../../session/agent-storage";
|
|
1
|
+
import type { AgentStorage } from "../../../session/agent-storage";
|
|
3
2
|
import { SearchProviderError, type SearchProviderId, type SearchSource } from "../../../web/search/types";
|
|
4
3
|
import { dateToAgeSeconds } from "../utils";
|
|
5
4
|
|
|
@@ -7,17 +6,24 @@ import { dateToAgeSeconds } from "../utils";
|
|
|
7
6
|
* Search for an API credential by checking an env-derived key first,
|
|
8
7
|
* then falling back to agent.db stored credentials for the given providers.
|
|
9
8
|
*
|
|
9
|
+
* The caller MUST supply an open {@link AgentStorage} handle so the helper
|
|
10
|
+
* never reaches out to global filesystem state; both the unified web_search
|
|
11
|
+
* chain and one-shot CLI calls open storage exactly once and thread it
|
|
12
|
+
* through every provider.
|
|
13
|
+
*
|
|
14
|
+
* @param storage - Open agent storage handle
|
|
10
15
|
* @param envKey - Pre-resolved environment variable value (or null)
|
|
11
16
|
* @param storageProviders - Provider names to look up in AgentStorage
|
|
12
17
|
*/
|
|
13
|
-
export
|
|
18
|
+
export function findCredential(
|
|
19
|
+
storage: AgentStorage | null | undefined,
|
|
14
20
|
envKey: string | null | undefined,
|
|
15
21
|
...storageProviders: string[]
|
|
16
|
-
):
|
|
22
|
+
): string | null {
|
|
17
23
|
if (envKey) return envKey;
|
|
24
|
+
if (!storage) return null;
|
|
18
25
|
|
|
19
26
|
try {
|
|
20
|
-
const storage = await AgentStorage.open(getAgentDbPath());
|
|
21
27
|
for (const provider of storageProviders) {
|
|
22
28
|
const records = storage.listAuthCredentials(provider);
|
|
23
29
|
for (const record of records) {
|
|
@@ -37,18 +43,6 @@ export async function findCredential(
|
|
|
37
43
|
return null;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
/**
|
|
41
|
-
* Probe whether a provider's API key lookup resolves to a truthy value.
|
|
42
|
-
* Swallows lookup errors and reports unavailability.
|
|
43
|
-
*/
|
|
44
|
-
export async function isApiKeyAvailable(findApiKey: () => string | null | Promise<string | null>) {
|
|
45
|
-
try {
|
|
46
|
-
return !!(await findApiKey());
|
|
47
|
-
} catch {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
46
|
/**
|
|
53
47
|
* Default hard ceiling for a single web-search round-trip. 60s tolerates
|
|
54
48
|
* legitimate slow LLM-mediated responses (anthropic web_search_20250305,
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* Calls Z.AI's remote MCP server (`webSearchPrime`) and adapts results into
|
|
5
5
|
* the unified SearchResponse shape used by the web search tool.
|
|
6
6
|
*/
|
|
7
|
-
import { getEnvApiKey } from "@oh-my-pi/pi-ai";
|
|
7
|
+
import { type AuthStorage, getEnvApiKey } from "@oh-my-pi/pi-ai";
|
|
8
8
|
import { asRecord, asString } from "../../../web/scrapers/utils";
|
|
9
9
|
import type { SearchResponse, SearchSource } from "../../../web/search/types";
|
|
10
10
|
import { SearchProviderError } from "../../../web/search/types";
|
|
11
11
|
import { dateToAgeSeconds } from "../utils";
|
|
12
12
|
import type { SearchParams } from "./base";
|
|
13
13
|
import { SearchProvider } from "./base";
|
|
14
|
-
import { classifyProviderHttpError,
|
|
14
|
+
import { classifyProviderHttpError, withHardTimeout } from "./utils";
|
|
15
15
|
|
|
16
16
|
const ZAI_MCP_URL = "https://api.z.ai/api/mcp/web_search_prime/mcp";
|
|
17
17
|
const ZAI_TOOL_NAME = "web_search_prime";
|
|
@@ -21,6 +21,8 @@ export interface ZaiSearchParams {
|
|
|
21
21
|
query: string;
|
|
22
22
|
num_results?: number;
|
|
23
23
|
signal?: AbortSignal;
|
|
24
|
+
authStorage: AuthStorage;
|
|
25
|
+
sessionId?: string;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
interface ZaiSearchResult {
|
|
@@ -51,9 +53,13 @@ interface JsonRpcPayload {
|
|
|
51
53
|
error?: JsonRpcError;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
/**
|
|
55
|
-
export async function findApiKey(
|
|
56
|
-
|
|
56
|
+
/** Resolve Z.AI API credentials through the unified auth storage pipeline. */
|
|
57
|
+
export async function findApiKey(
|
|
58
|
+
authStorage: AuthStorage,
|
|
59
|
+
sessionId?: string,
|
|
60
|
+
signal?: AbortSignal,
|
|
61
|
+
): Promise<string | null> {
|
|
62
|
+
return (await authStorage.getApiKey("zai", sessionId, { signal })) ?? null;
|
|
57
63
|
}
|
|
58
64
|
|
|
59
65
|
async function callZaiTool(apiKey: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<unknown> {
|
|
@@ -272,7 +278,7 @@ function toSources(results: ZaiSearchResult[]): SearchSource[] {
|
|
|
272
278
|
|
|
273
279
|
/** Execute Z.AI web search via remote MCP endpoint. */
|
|
274
280
|
export async function searchZai(params: ZaiSearchParams): Promise<SearchResponse> {
|
|
275
|
-
const apiKey = await findApiKey();
|
|
281
|
+
const apiKey = await findApiKey(params.authStorage, params.sessionId, params.signal);
|
|
276
282
|
if (!apiKey) {
|
|
277
283
|
throw new Error("Z.AI credentials not found. Set ZAI_API_KEY or login with 'omp /login zai'.");
|
|
278
284
|
}
|
|
@@ -298,8 +304,8 @@ export class ZaiProvider extends SearchProvider {
|
|
|
298
304
|
readonly id = "zai";
|
|
299
305
|
readonly label = "Z.AI";
|
|
300
306
|
|
|
301
|
-
isAvailable(): Promise<boolean> {
|
|
302
|
-
return
|
|
307
|
+
isAvailable(authStorage: AuthStorage): Promise<boolean> | boolean {
|
|
308
|
+
return authStorage.hasAuth("zai") || !!getEnvApiKey("zai");
|
|
303
309
|
}
|
|
304
310
|
|
|
305
311
|
search(params: SearchParams): Promise<SearchResponse> {
|
|
@@ -307,6 +313,8 @@ export class ZaiProvider extends SearchProvider {
|
|
|
307
313
|
query: params.query,
|
|
308
314
|
num_results: params.numSearchResults ?? params.limit,
|
|
309
315
|
signal: params.signal,
|
|
316
|
+
authStorage: params.authStorage,
|
|
317
|
+
sessionId: params.sessionId,
|
|
310
318
|
});
|
|
311
319
|
}
|
|
312
320
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { HashlineCursor, HashlineEdit } from "./types";
|
|
2
|
-
export declare function cloneCursor(cursor: HashlineCursor): HashlineCursor;
|
|
3
|
-
export declare function parseHashline(diff: string): HashlineEdit[];
|
|
4
|
-
export declare function parseHashlineWithWarnings(diff: string): {
|
|
5
|
-
edits: HashlineEdit[];
|
|
6
|
-
warnings: string[];
|
|
7
|
-
};
|
|
@@ -1,7 +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 { DiscoverableMCPSearchDocument, DiscoverableMCPSearchIndex, DiscoverableMCPSearchResult, DiscoverableMCPTool, DiscoverableMCPToolServerSummary, DiscoverableMCPToolSummary, } from "../tool-discovery/tool-index";
|
|
7
|
-
export { buildDiscoverableMCPSearchIndex, collectDiscoverableMCPTools, formatDiscoverableMCPToolServerSummary, getDiscoverableMCPTool, isMCPToolName, searchDiscoverableMCPTools, selectDiscoverableMCPToolNamesByServer, summarizeDiscoverableMCPTools, } from "../tool-discovery/tool-index";
|
|
@@ -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,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,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;
|