pi-agent-ide 0.7.1 → 0.7.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 +37 -0
- package/dist/chunk-6U5OU77O.js +3 -0
- package/dist/chunk-EURHXLN3.js +2 -0
- package/dist/{chunk-WMO6RNE2.js → chunk-F6IWZKOG.js} +6 -6
- package/dist/{chunk-HZEY4GT4.js → chunk-H445SHSJ.js} +2 -2
- package/dist/chunk-IG56UGSO.js +2 -0
- package/dist/chunk-IICJXZBU.js +6 -0
- package/dist/{chunk-XYS4FSCC.js → chunk-IM24DB3K.js} +1 -1
- package/dist/{chunk-PKKDDIWW.js → chunk-KOVPDKSJ.js} +1 -1
- package/dist/chunk-MXLSGMRZ.js +3 -0
- package/dist/chunk-OB46OPMZ.js +1 -0
- package/dist/chunk-PKSQT6TC.js +1 -0
- package/dist/{chunk-PNU3E7IO.js → chunk-Q6CZ6GBR.js} +2 -2
- package/dist/chunk-QUYXINGZ.js +7 -0
- package/dist/{chunk-OMVRLWMX.js → chunk-SBP3ABH4.js} +1 -1
- package/dist/{chunk-4GCWGE2C.js → chunk-SJ4UZ4GU.js} +1 -1
- package/dist/{chunk-2TRHFMCZ.js → chunk-SNF7PDDX.js} +1 -1
- package/dist/{chunk-YP46DVVP.js → chunk-STBJO3Z3.js} +1 -1
- package/dist/{chunk-76ZK5ODR.js → chunk-TQGE7RH6.js} +13 -13
- package/dist/{chunk-LEEQIQ7D.js → chunk-XDG7EQRN.js} +6 -6
- package/dist/chunk-YWQS33DF.js +1 -0
- package/dist/chunk-ZIWPKIBZ.js +1 -0
- package/dist/entry-11.js +1 -1
- package/dist/entry-13.js +1 -1
- package/dist/entry-14.js +1 -1
- package/dist/entry-15.js +1 -1
- package/dist/entry-17.js +1 -1
- package/dist/entry-25.js +1 -1
- package/dist/entry-26.js +1 -1
- package/dist/entry-27.js +1 -1
- package/dist/entry-28.js +1 -1
- package/dist/entry-29.js +1 -1
- package/dist/entry-31.js +13 -12
- package/dist/entry-33.js +2 -1
- package/dist/entry-37.js +2 -2
- package/dist/entry-42.js +1 -1
- package/dist/entry-44.js +1 -1
- package/dist/entry-45.js +20 -12
- package/dist/entry-46.js +1 -1
- package/dist/entry-49.js +1 -1
- package/dist/entry-50.js +1 -1
- package/dist/entry-51.js +7 -6
- package/dist/entry-52.js +1 -1
- package/dist/entry-53.js +1 -1
- package/dist/entry-54.js +1 -1
- package/dist/entry-56.js +1 -1
- package/dist/entry-58.js +1 -1
- package/dist/entry-60.js +1 -1
- package/dist/entry-62.js +1 -1
- package/dist/entry-65.js +1 -1
- package/dist/entry-66.js +1 -1
- package/dist/entry-68.js +1 -1
- package/dist/entry-70.js +1 -1
- package/dist/entry-75.js +1 -1
- package/dist/entry-77.js +51 -42
- package/dist/entry-78.js +14 -14
- package/dist/entry-79.js +1 -1
- package/dist/entry-82.js +5 -5
- package/dist/entry-83.js +1 -1
- package/dist/entry-84.js +1 -1
- package/dist/entry-85.js +1 -1
- package/dist/entry-86.js +1 -1
- package/dist/pi-agent-ide.js +34 -11
- package/docs/agent-guides/editing.md +5 -5
- package/docs/agent-guides/git-changes.md +10 -0
- package/docs/agent-guides/read-resources.md +9 -46
- package/docs/agent-guides/search-code.md +7 -1
- package/docs/agent-guides/select-code.md +1 -0
- package/docs/agent-guides/terminal.md +9 -1
- package/docs/configuration.md +1 -1
- package/docs/releases.md +4 -0
- package/docs/research/native-codemode-batch-decision.md +2 -0
- package/docs/structured-results.md +2 -2
- package/docs/tools.md +10 -2
- package/node_modules/pi-agent-doctor/package.json +1 -1
- package/node_modules/pi-agent-documentation/package.json +1 -1
- package/node_modules/pi-agent-filesystem/package.json +7 -7
- package/node_modules/pi-agent-filesystem-image/package.json +3 -3
- package/node_modules/pi-agent-filesystem-jq/package.json +5 -5
- package/node_modules/pi-agent-filesystem-jq/src/jq.ts +4 -1
- package/node_modules/pi-agent-filesystem-pdf/package.json +3 -3
- package/node_modules/pi-agent-filesystem-text/package.json +3 -3
- package/node_modules/pi-agent-ide-ast/package.json +13 -13
- package/node_modules/pi-agent-ide-ast/src/extension.ts +0 -2
- package/node_modules/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/node_modules/pi-agent-ide-ast/src/search-resolver.ts +0 -3
- package/node_modules/pi-agent-ide-ast/src/select-schema.ts +8 -6
- package/node_modules/pi-agent-ide-ast/src/tool-select.ts +13 -5
- package/node_modules/pi-agent-ide-changes/package.json +8 -8
- package/node_modules/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
- package/node_modules/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/node_modules/pi-agent-ide-formatter/package.json +3 -3
- package/node_modules/pi-agent-ide-languages/package.json +2 -2
- package/node_modules/pi-agent-ide-lint/package.json +7 -7
- package/node_modules/pi-agent-ide-lsp/package.json +9 -9
- package/node_modules/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
- package/node_modules/pi-agent-image/package.json +2 -2
- package/node_modules/pi-agent-invariant/package.json +1 -1
- package/node_modules/pi-agent-pdf/package.json +2 -2
- package/node_modules/pi-agent-read/package.json +7 -7
- package/node_modules/pi-agent-read/src/api/read-parameters.ts +3 -3
- package/node_modules/pi-agent-read/src/api/tools/read.ts +11 -0
- package/node_modules/pi-agent-read/src/core/extension.ts +1 -1
- package/node_modules/pi-agent-read/src/core/read-core.ts +5 -1
- package/node_modules/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/node_modules/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/node_modules/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/node_modules/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/node_modules/pi-agent-read/src/core/tools/tool-read.ts +99 -44
- package/node_modules/pi-agent-resource/package.json +1 -1
- package/node_modules/pi-agent-resource/src/index.ts +1 -0
- package/node_modules/pi-agent-resource/src/result-targets.ts +6 -3
- package/node_modules/{pi-agent-read/src/core/tools/read → pi-agent-resource/src}/temp-resource-store.ts +17 -7
- package/node_modules/pi-agent-search/package.json +5 -5
- package/node_modules/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/node_modules/pi-agent-search/src/api/search-parameters.ts +2 -2
- package/node_modules/pi-agent-search/src/core/extension.ts +2 -1
- package/node_modules/pi-agent-search/src/core/search-core.ts +13 -4
- package/node_modules/pi-agent-search-text/package.json +7 -7
- package/node_modules/pi-agent-search-text/src/resolvers.ts +11 -1
- package/node_modules/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/node_modules/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/node_modules/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/node_modules/pi-agent-search-text/src/search-result.ts +17 -3
- package/node_modules/pi-agent-text/package.json +2 -2
- package/node_modules/pi-agent-text-anchor-constant/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-exact/package.json +3 -3
- package/node_modules/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/node_modules/pi-agent-text-editor/package.json +9 -9
- package/node_modules/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/node_modules/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
- package/node_modules/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/node_modules/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
- package/node_modules/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
- package/node_modules/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/node_modules/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -151
- package/node_modules/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/node_modules/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/node_modules/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
- package/node_modules/pi-agent-text-editor/src/core/structured-result.ts +14 -13
- package/node_modules/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
- package/node_modules/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/node_modules/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
- package/node_modules/pi-agent-text-editor/src/core/text-mutation.ts +381 -187
- package/node_modules/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +4 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -2
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
- package/node_modules/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/node_modules/pi-agent-text-editor-renderer/package.json +5 -5
- package/node_modules/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/node_modules/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
- package/node_modules/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/node_modules/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/node_modules/pi-agent-tool-call-interception/package.json +2 -2
- package/node_modules/pi-agent-tool-ui/package.json +1 -1
- package/node_modules/pi-agent-web/package.json +7 -7
- package/node_modules/pi-agent-web/src/resolver.ts +11 -13
- package/node_modules/pi-agent-web-html/package.json +2 -2
- package/node_modules/pi-agent-web-image/package.json +3 -3
- package/node_modules/pi-agent-web-pdf/package.json +3 -3
- package/node_modules/pi-agent-web-text/package.json +3 -3
- package/package.json +35 -35
- package/src/composite/nested-tool-rendering.ts +64 -6
- package/src/composite/output-limits.ts +125 -0
- package/src/composite/responses-tools.ts +25 -0
- package/src/composite/text-results.ts +158 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/package.json +5 -5
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-jq/src/jq.ts +4 -1
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-filesystem/plugins/pi-agent-filesystem-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/package.json +7 -7
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-html/package.json +2 -2
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-image/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-pdf/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/plugins/pi-agent-web-text/package.json +3 -3
- package/src/extensions/pi-agent-read/extensions/pi-agent-web/src/resolver.ts +11 -13
- package/src/extensions/pi-agent-read/package.json +7 -7
- package/src/extensions/pi-agent-read/src/api/read-parameters.ts +3 -3
- package/src/extensions/pi-agent-read/src/api/tools/read.ts +11 -0
- package/src/extensions/pi-agent-read/src/core/extension.ts +1 -1
- package/src/extensions/pi-agent-read/src/core/read-core.ts +5 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/output-truncation.ts +91 -18
- package/src/extensions/pi-agent-read/src/core/tools/read/raw-read.ts +8 -2
- package/src/extensions/pi-agent-read/src/core/tools/read/read-renderer.ts +38 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/read-result.ts +57 -2
- package/src/extensions/pi-agent-read/src/core/tools/tool-read.ts +99 -44
- package/src/extensions/pi-agent-search/package.json +5 -5
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/package.json +7 -7
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/resolvers.ts +11 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/scoped-search.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts +42 -32
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-recipe.ts +1 -1
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-renderer.ts +6 -0
- package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-result.ts +17 -3
- package/src/extensions/pi-agent-search/src/api/fuzzy.ts +5 -1
- package/src/extensions/pi-agent-search/src/api/search-parameters.ts +2 -2
- package/src/extensions/pi-agent-search/src/core/extension.ts +2 -1
- package/src/extensions/pi-agent-search/src/core/search-core.ts +13 -4
- package/src/extensions/pi-agent-text-editor/package.json +9 -9
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-constant/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-exact/package.json +3 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-anchor-line-hash/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/package.json +5 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/mutation-panel.ts +11 -0
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/renderer.ts +54 -5
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-renderer/src/status-summary.ts +18 -3
- package/src/extensions/pi-agent-text-editor/plugins/pi-agent-text-editor-stale-anchor/package.json +4 -4
- package/src/extensions/pi-agent-text-editor/src/api/edit-completion.ts +2 -2
- package/src/extensions/pi-agent-text-editor/src/api/mutation-result.ts +1 -2
- package/src/extensions/pi-agent-text-editor/src/api/native-edit-batch-event.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/api/stale-anchor-message.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/diff-tool.ts +54 -12
- package/src/extensions/pi-agent-text-editor/src/core/editing-guidelines.ts +1 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-agent-result.ts +35 -6
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result/file-mutation-result.ts +19 -1
- package/src/extensions/pi-agent-text-editor/src/core/mutation-result-targets.ts +132 -11
- package/src/extensions/pi-agent-text-editor/src/core/native-text-edit-batch.ts +232 -151
- package/src/extensions/pi-agent-text-editor/src/core/post-edit-scope.ts +34 -10
- package/src/extensions/pi-agent-text-editor/src/core/result-input.ts +24 -4
- package/src/extensions/pi-agent-text-editor/src/core/result-transfer.ts +7 -2
- package/src/extensions/pi-agent-text-editor/src/core/structured-result.ts +14 -13
- package/src/extensions/pi-agent-text-editor/src/core/text-change-engine.ts +5 -1
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch-registrar.ts +152 -22
- package/src/extensions/pi-agent-text-editor/src/core/text-edit-batch.ts +4 -0
- package/src/extensions/pi-agent-text-editor/src/core/text-editor-core.ts +76 -32
- package/src/extensions/pi-agent-text-editor/src/core/text-mutation.ts +381 -187
- package/src/extensions/pi-agent-text-editor/src/tools/text-tool-schema-properties.ts +4 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-copy.ts +9 -2
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-delete.ts +9 -4
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-insert.ts +7 -8
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-replace.ts +2 -3
- package/src/extensions/pi-agent-text-editor/src/tools/tool-text-write.ts +10 -4
- package/src/pi-agent-ide.ts +11 -0
- package/src/plugins/pi-agent-ide-ast/package.json +13 -13
- package/src/plugins/pi-agent-ide-ast/src/extension.ts +0 -2
- package/src/plugins/pi-agent-ide-ast/src/overflow-handler.ts +2 -2
- package/src/plugins/pi-agent-ide-ast/src/search-resolver.ts +0 -3
- package/src/plugins/pi-agent-ide-ast/src/select-schema.ts +8 -6
- package/src/plugins/pi-agent-ide-ast/src/tool-select.ts +13 -5
- package/src/plugins/pi-agent-ide-changes/package.json +8 -8
- package/src/plugins/pi-agent-ide-changes/src/tool-index-change.ts +66 -4
- package/src/plugins/pi-agent-ide-changes/src/tool-text-undo.ts +8 -11
- package/src/plugins/pi-agent-ide-debugger/index.ts +17 -7
- package/src/plugins/pi-agent-ide-debugger/src/dap-client.ts +5 -0
- package/src/plugins/pi-agent-ide-debugger/src/session-manager.ts +93 -38
- package/src/plugins/pi-agent-ide-diagnostics/src/extension.ts +3 -2
- package/src/plugins/pi-agent-ide-formatter/package.json +3 -3
- package/src/plugins/pi-agent-ide-languages/package.json +2 -2
- package/src/plugins/pi-agent-ide-lint/package.json +7 -7
- package/src/plugins/pi-agent-ide-lsp/package.json +9 -9
- package/src/plugins/pi-agent-ide-lsp/src/search-resolver.ts +0 -1
- package/src/plugins/pi-agent-ide-terminal/src/output-limits.ts +3 -3
- package/src/plugins/pi-agent-ide-terminal/src/tools.ts +3 -3
- package/src/plugins/pi-agent-ide-vision/index.ts +1 -0
- package/src/post-edit/gate.ts +13 -2
- package/dist/chunk-4XMY4H4V.js +0 -1
- package/dist/chunk-64M3SQPG.js +0 -3
- package/dist/chunk-CWD4O5PM.js +0 -3
- package/dist/chunk-D3WTDA6V.js +0 -2
- package/dist/chunk-EAZGN5ND.js +0 -7
- package/dist/chunk-GXEGY7GV.js +0 -1
- package/dist/chunk-MBUXFKIW.js +0 -3
- package/dist/chunk-PGIVHICI.js +0 -1
- package/dist/chunk-VMTR74FF.js +0 -2
- package/dist/chunk-WU6ZK6YD.js +0 -1
- package/src/extensions/pi-agent-read/src/core/tools/read/temp-resource-store.ts +0 -105
|
@@ -43,18 +43,15 @@ import {
|
|
|
43
43
|
type ResourceResolverRegistration,
|
|
44
44
|
type TextTargetResolverRegistration,
|
|
45
45
|
} from "#src/api/tools/read.js";
|
|
46
|
-
import {
|
|
47
|
-
limitReadOutput,
|
|
48
|
-
READ_OUTPUT_MAX_BYTES,
|
|
49
|
-
READ_OUTPUT_MAX_LINES,
|
|
50
|
-
} from "#src/core/tools/read/output-truncation.js";
|
|
46
|
+
import { explainReadWindow, limitReadOutput } from "#src/core/tools/read/output-truncation.js";
|
|
51
47
|
import { createReadResultRenderer, renderReadCall } from "#src/core/tools/read/read-renderer.js";
|
|
52
48
|
import {
|
|
53
49
|
createReadState,
|
|
54
50
|
failureResult,
|
|
55
51
|
projectReadState,
|
|
52
|
+
withReadCancellation,
|
|
56
53
|
} from "#src/core/tools/read/read-result.js";
|
|
57
|
-
import { TempResourceStore } from "
|
|
54
|
+
import { TempResourceStore } from "pi-agent-resource";
|
|
58
55
|
|
|
59
56
|
import {
|
|
60
57
|
type readParameters,
|
|
@@ -116,6 +113,8 @@ export interface ReadToolContributions {
|
|
|
116
113
|
export interface ReadTool {
|
|
117
114
|
/** Shares the read runtime's temporary resource store with composed operations. */
|
|
118
115
|
saveTemporary(text: string): Promise<string>;
|
|
116
|
+
/** Sets the saver used before agent-facing text is truncated. */
|
|
117
|
+
setOutputSaver(saver: (text: string) => Promise<string>): void;
|
|
119
118
|
readonly tool: ToolDefinition<typeof readParameters, ReadResultDetails>;
|
|
120
119
|
execute(
|
|
121
120
|
request: ReadPipelineContext["request"],
|
|
@@ -133,6 +132,7 @@ export function createReadTool(
|
|
|
133
132
|
parameterDescriptions?: () => ReadParameterText,
|
|
134
133
|
): ReadTool {
|
|
135
134
|
const temporaryResources = new TempResourceStore();
|
|
135
|
+
let outputSaver: ((text: string) => Promise<string>) | undefined;
|
|
136
136
|
const resolvers: RegisteredResolver[] = [
|
|
137
137
|
{
|
|
138
138
|
resolver: temporaryResources.resolver,
|
|
@@ -154,6 +154,9 @@ export function createReadTool(
|
|
|
154
154
|
|
|
155
155
|
return {
|
|
156
156
|
saveTemporary: (text) => temporaryResources.save(text),
|
|
157
|
+
setOutputSaver(saver) {
|
|
158
|
+
outputSaver = saver;
|
|
159
|
+
},
|
|
157
160
|
tool: {
|
|
158
161
|
name: toolId,
|
|
159
162
|
exposure: "direct",
|
|
@@ -168,9 +171,7 @@ export function createReadTool(
|
|
|
168
171
|
label: toolId,
|
|
169
172
|
|
|
170
173
|
promptSnippet: "Read supported sources as text or bytes, with optional views",
|
|
171
|
-
|
|
172
|
-
return `Use read to inspect supported resources. path selects the source; offset and limit select a bounded window; views request source-specific presentations. Text output is limited to ${READ_OUTPUT_MAX_LINES} lines or ${READ_OUTPUT_MAX_BYTES / 1024}KB; follow a returned continuation offset or temp: reference when present.`;
|
|
173
|
-
},
|
|
174
|
+
description: "Use read to inspect files and other supported resources.",
|
|
174
175
|
get promptGuidelines(): string[] {
|
|
175
176
|
return [
|
|
176
177
|
"Use read to inspect supported sources and search to locate workspace content.",
|
|
@@ -226,8 +227,10 @@ export function createReadTool(
|
|
|
226
227
|
fragments,
|
|
227
228
|
targetResolvers,
|
|
228
229
|
resourceGuards,
|
|
230
|
+
"agent",
|
|
231
|
+
outputSaver,
|
|
229
232
|
);
|
|
230
|
-
return structuredRead(result);
|
|
233
|
+
return structuredRead(withReadCancellation(result, parameters.path, signal));
|
|
231
234
|
} catch (error) {
|
|
232
235
|
if (signal?.aborted) throw error;
|
|
233
236
|
return structuredRead(
|
|
@@ -240,8 +243,8 @@ export function createReadTool(
|
|
|
240
243
|
}
|
|
241
244
|
},
|
|
242
245
|
},
|
|
243
|
-
execute(request, context, audience = "agent"): Promise<ReadToolResult> {
|
|
244
|
-
|
|
246
|
+
async execute(request, context, audience = "agent"): Promise<ReadToolResult> {
|
|
247
|
+
const result = await executeRead(
|
|
245
248
|
request,
|
|
246
249
|
context,
|
|
247
250
|
resolvers,
|
|
@@ -252,7 +255,9 @@ export function createReadTool(
|
|
|
252
255
|
targetResolvers,
|
|
253
256
|
resourceGuards,
|
|
254
257
|
audience,
|
|
258
|
+
outputSaver,
|
|
255
259
|
);
|
|
260
|
+
return withReadCancellation(result, request.path, context.signal);
|
|
256
261
|
},
|
|
257
262
|
registerContributions(pluginId, contributions): void {
|
|
258
263
|
const incomingResourceGuards = [...(contributions.resourceGuards ?? [])];
|
|
@@ -370,12 +375,16 @@ async function executeRead(
|
|
|
370
375
|
}[],
|
|
371
376
|
resourceGuards: readonly RegisteredResourceGuard[],
|
|
372
377
|
audience: "agent" | "script" = "agent",
|
|
378
|
+
outputSaver?: (text: string) => Promise<string>,
|
|
373
379
|
): Promise<ReadToolResult> {
|
|
374
380
|
if (request.path?.startsWith("raw:"))
|
|
375
381
|
return readRaw(request, resolverContext, audience, resourceGuards);
|
|
376
382
|
resolverContext = { ...resolverContext, audience };
|
|
377
383
|
const limitOutput: typeof limitReadOutput =
|
|
378
|
-
audience === "script"
|
|
384
|
+
audience === "script"
|
|
385
|
+
? async (result) => result
|
|
386
|
+
: (result, request, fallback, options) =>
|
|
387
|
+
limitReadOutput(result, request, outputSaver ?? fallback, options);
|
|
379
388
|
const resolverSnapshot = [...resolvers].sort(
|
|
380
389
|
(left, right) => left.priority - right.priority || left.order - right.order,
|
|
381
390
|
);
|
|
@@ -397,7 +406,18 @@ async function executeRead(
|
|
|
397
406
|
];
|
|
398
407
|
const requestedViews = new Set(rawRequestedViews.map(viewName));
|
|
399
408
|
const knownViews = new Set([...viewSnapshot.map(({ registration }) => registration.view)]);
|
|
400
|
-
const
|
|
409
|
+
const explicitViews = [...new Set(request.views ?? [])];
|
|
410
|
+
const nativeViews = new Set(
|
|
411
|
+
viewSnapshot
|
|
412
|
+
.filter(({ registration }) => registration.contentKind === "any")
|
|
413
|
+
.map(({ registration }) => registration.view),
|
|
414
|
+
);
|
|
415
|
+
const viewWarnings: ReadViewWarnings = {
|
|
416
|
+
ignored: explicitViews.filter((view) => !knownViews.has(viewName(view))),
|
|
417
|
+
textOnly: explicitViews.filter(
|
|
418
|
+
(view) => knownViews.has(viewName(view)) && !nativeViews.has(viewName(view)),
|
|
419
|
+
),
|
|
420
|
+
};
|
|
401
421
|
if (request.path !== undefined && targetSnapshot.length > 0) {
|
|
402
422
|
const targeted = await resolveTextTargets(
|
|
403
423
|
request,
|
|
@@ -407,9 +427,10 @@ async function executeRead(
|
|
|
407
427
|
handlerSnapshot,
|
|
408
428
|
viewSnapshot,
|
|
409
429
|
requestedViews,
|
|
410
|
-
|
|
430
|
+
viewWarnings,
|
|
411
431
|
audience,
|
|
412
432
|
resourceGuards,
|
|
433
|
+
outputSaver,
|
|
413
434
|
);
|
|
414
435
|
if (targeted !== undefined) return targeted;
|
|
415
436
|
}
|
|
@@ -419,7 +440,7 @@ async function executeRead(
|
|
|
419
440
|
const preRead = await runPreReadHandlers(pipeline, handlerSnapshot);
|
|
420
441
|
|
|
421
442
|
if (preRead.kind === "return") {
|
|
422
|
-
return
|
|
443
|
+
return withViewWarnings(await limitOutput(preRead.result, pipeline.request), viewWarnings);
|
|
423
444
|
}
|
|
424
445
|
|
|
425
446
|
pipeline = preRead.context;
|
|
@@ -489,23 +510,23 @@ async function executeRead(
|
|
|
489
510
|
}
|
|
490
511
|
|
|
491
512
|
if (pipeline.state?.textMode === "final") {
|
|
492
|
-
return
|
|
513
|
+
return withViewWarnings(
|
|
493
514
|
await limitOutput(
|
|
494
515
|
projectReadState(pipeline.state, pipeline.request, { originLine: origin, audience }),
|
|
495
516
|
pipeline.request,
|
|
496
517
|
undefined,
|
|
497
518
|
{ originLine: origin },
|
|
498
519
|
),
|
|
499
|
-
|
|
520
|
+
viewWarnings,
|
|
500
521
|
);
|
|
501
522
|
}
|
|
502
523
|
|
|
503
524
|
const processed = await runReadHandlers(pipeline, handlerSnapshot);
|
|
504
525
|
|
|
505
526
|
if (processed.kind === "return") {
|
|
506
|
-
return
|
|
527
|
+
return withViewWarnings(
|
|
507
528
|
await limitOutput(processed.result, pipeline.request, undefined, { originLine: origin }),
|
|
508
|
-
|
|
529
|
+
viewWarnings,
|
|
509
530
|
);
|
|
510
531
|
}
|
|
511
532
|
|
|
@@ -523,9 +544,9 @@ async function executeRead(
|
|
|
523
544
|
pipeline.request.limit === undefined && pipeline.state?.preserveTruncatedOutput === true
|
|
524
545
|
? (text: string): Promise<string> => temporaryResources.save(text)
|
|
525
546
|
: undefined;
|
|
526
|
-
return
|
|
547
|
+
return withViewWarnings(
|
|
527
548
|
await limitOutput(result, pipeline.request, saveFullOutput, { originLine: origin }),
|
|
528
|
-
|
|
549
|
+
viewWarnings,
|
|
529
550
|
);
|
|
530
551
|
}
|
|
531
552
|
|
|
@@ -559,12 +580,16 @@ async function resolveTextTargets(
|
|
|
559
580
|
handlers: readonly RegisteredHandler[],
|
|
560
581
|
views: readonly RegisteredView[],
|
|
561
582
|
requestedViews: ReadonlySet<string>,
|
|
562
|
-
|
|
583
|
+
viewWarnings: ReadViewWarnings,
|
|
563
584
|
audience: "agent" | "script",
|
|
564
585
|
resourceGuards: readonly RegisteredResourceGuard[],
|
|
586
|
+
outputSaver?: (text: string) => Promise<string>,
|
|
565
587
|
): Promise<ReadToolResult | undefined> {
|
|
566
588
|
const limitOutput: typeof limitReadOutput =
|
|
567
|
-
audience === "script"
|
|
589
|
+
audience === "script"
|
|
590
|
+
? async (result) => result
|
|
591
|
+
: (result, request, fallback, options) =>
|
|
592
|
+
limitReadOutput(result, request, outputSaver ?? fallback, options);
|
|
568
593
|
for (const { resolver } of targetResolvers) {
|
|
569
594
|
let rawAttempt: unknown;
|
|
570
595
|
try {
|
|
@@ -634,7 +659,7 @@ async function resolveTextTargets(
|
|
|
634
659
|
const preRead = await runPreReadHandlers(rangePipeline, handlers);
|
|
635
660
|
if (preRead.kind === "return") {
|
|
636
661
|
if (preRead.result.isError === true)
|
|
637
|
-
return
|
|
662
|
+
return withViewWarnings(preRead.result, viewWarnings);
|
|
638
663
|
return preRead.result;
|
|
639
664
|
}
|
|
640
665
|
rangePipeline = preRead.context;
|
|
@@ -646,12 +671,12 @@ async function resolveTextTargets(
|
|
|
646
671
|
request.path ?? target.source,
|
|
647
672
|
);
|
|
648
673
|
if (resolved.kind === "return") {
|
|
649
|
-
return
|
|
674
|
+
return withViewWarnings(resolved.result, viewWarnings);
|
|
650
675
|
}
|
|
651
676
|
const processed = await runReadHandlers(resolved.context, handlers);
|
|
652
677
|
if (processed.kind === "return") {
|
|
653
678
|
if (processed.result.isError === true)
|
|
654
|
-
return
|
|
679
|
+
return withViewWarnings(processed.result, viewWarnings);
|
|
655
680
|
return processed.result;
|
|
656
681
|
}
|
|
657
682
|
const presented = await runTextPresenters(processed.context, views, requestedViews);
|
|
@@ -660,18 +685,26 @@ async function resolveTextTargets(
|
|
|
660
685
|
originLine: range.start.lineNumber,
|
|
661
686
|
});
|
|
662
687
|
const postRead = await runPostReadHandlers({ ...presented, result: projected }, handlers);
|
|
663
|
-
if (projected.isError === true) return
|
|
688
|
+
if (projected.isError === true) return withViewWarnings(projected, viewWarnings);
|
|
664
689
|
const result =
|
|
665
690
|
postRead.kind === "return" ? postRead.result : requiredValue(postRead.context.result);
|
|
666
|
-
if (result.isError === true) return
|
|
667
|
-
return
|
|
691
|
+
if (result.isError === true) return withViewWarnings(result, viewWarnings);
|
|
692
|
+
return audience === "script"
|
|
693
|
+
? result
|
|
694
|
+
: explainReadWindow(
|
|
695
|
+
result,
|
|
696
|
+
{ ...presented.request, limit: request.limit },
|
|
697
|
+
{
|
|
698
|
+
originLine: range.start.lineNumber,
|
|
699
|
+
},
|
|
700
|
+
);
|
|
668
701
|
});
|
|
669
702
|
});
|
|
670
703
|
const completed = await Promise.allSettled(pending);
|
|
671
704
|
for (const outcome of completed) {
|
|
672
705
|
if (outcome.status === "rejected") throw outcome.reason;
|
|
673
706
|
const result = outcome.value;
|
|
674
|
-
if (result.isError === true) return
|
|
707
|
+
if (result.isError === true) return withViewWarnings(result, viewWarnings);
|
|
675
708
|
for (const block of result.content) {
|
|
676
709
|
if (block.type === "text") chunks.push(block.text);
|
|
677
710
|
}
|
|
@@ -693,9 +726,9 @@ async function resolveTextTargets(
|
|
|
693
726
|
? { source: request.path, resources }
|
|
694
727
|
: (firstDetails ?? { source: request.path }),
|
|
695
728
|
} satisfies ReadToolResult;
|
|
696
|
-
return
|
|
729
|
+
return withViewWarnings(
|
|
697
730
|
await limitOutput(aggregate, { path: request.path, views: request.views }),
|
|
698
|
-
|
|
731
|
+
viewWarnings,
|
|
699
732
|
);
|
|
700
733
|
}
|
|
701
734
|
return undefined;
|
|
@@ -733,7 +766,7 @@ async function resolveAnchoredOrigin(
|
|
|
733
766
|
code: "UNSUPPORTED_RANGE",
|
|
734
767
|
source: state.source,
|
|
735
768
|
resolverId: state.resolvedBy,
|
|
736
|
-
message: "Anchored reads require textual content",
|
|
769
|
+
message: "Anchored reads require textual content. Read this source without an anchor.",
|
|
737
770
|
});
|
|
738
771
|
}
|
|
739
772
|
|
|
@@ -1110,21 +1143,43 @@ function viewName(view: string): string {
|
|
|
1110
1143
|
return separator < 0 ? view : view.slice(0, separator);
|
|
1111
1144
|
}
|
|
1112
1145
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
}
|
|
1146
|
+
interface ReadViewWarnings {
|
|
1147
|
+
readonly ignored: readonly string[];
|
|
1148
|
+
readonly textOnly: readonly string[];
|
|
1149
|
+
}
|
|
1118
1150
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1151
|
+
/** Reports unused views without changing source data or discarding native content. */
|
|
1152
|
+
function withViewWarnings(result: ReadToolResult, requested: ReadViewWarnings): ReadToolResult {
|
|
1153
|
+
const messages: string[] = [];
|
|
1154
|
+
if (requested.ignored.length > 0) {
|
|
1155
|
+
messages.push(
|
|
1156
|
+
requested.ignored.length === 1
|
|
1157
|
+
? `Unknown view ignored: ${requested.ignored[0]}. Remove it or choose a supported view from the views parameter.`
|
|
1158
|
+
: `Unknown views ignored: ${requested.ignored.join(", ")}. Remove these entries or choose supported views from the views parameter.`,
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
if (result.isError !== true && result.content.some((block) => block.type !== "text")) {
|
|
1162
|
+
for (const view of requested.textOnly) {
|
|
1163
|
+
messages.push(
|
|
1164
|
+
`View not applied: ${view} requires text. Read a text source to use ${viewName(view)}.`,
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
if (messages.length === 0 || result.details.viewWarnings !== undefined) return result;
|
|
1169
|
+
const note = messages.join("\n");
|
|
1170
|
+
const first = result.content[0];
|
|
1121
1171
|
const content =
|
|
1122
|
-
|
|
1123
|
-
|
|
1172
|
+
result.content.length === 1 && first?.type === "text"
|
|
1173
|
+
? [{ ...first, text: `${note}\n${first.text}` }]
|
|
1174
|
+
: [{ type: "text" as const, text: note }, ...result.content];
|
|
1124
1175
|
return {
|
|
1125
1176
|
...result,
|
|
1126
1177
|
content,
|
|
1127
|
-
details: {
|
|
1178
|
+
details: {
|
|
1179
|
+
...result.details,
|
|
1180
|
+
...(requested.ignored.length === 0 ? {} : { ignoredViews: requested.ignored }),
|
|
1181
|
+
viewWarnings: messages,
|
|
1182
|
+
},
|
|
1128
1183
|
};
|
|
1129
1184
|
}
|
|
1130
1185
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"pi-agent-documentation": "0.7.
|
|
24
|
-
"pi-agent-resource": "0.7.
|
|
25
|
-
"pi-agent-tool-call-interception": "0.7.
|
|
26
|
-
"pi-agent-tool-ui": "0.7.
|
|
23
|
+
"pi-agent-documentation": "0.7.2",
|
|
24
|
+
"pi-agent-resource": "0.7.2",
|
|
25
|
+
"pi-agent-tool-call-interception": "0.7.2",
|
|
26
|
+
"pi-agent-tool-ui": "0.7.2"
|
|
27
27
|
},
|
|
28
28
|
"pi": {
|
|
29
29
|
"extensions": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-agent-search-text",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"imports": {
|
|
6
6
|
"#src/*": "./src/*"
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"pi-agent-doctor": "0.7.
|
|
28
|
-
"pi-agent-invariant": "0.7.
|
|
29
|
-
"pi-agent-search": "0.7.
|
|
30
|
-
"pi-agent-text": "0.7.
|
|
31
|
-
"pi-agent-text-editor": "0.7.
|
|
32
|
-
"pi-agent-tool-ui": "0.7.
|
|
27
|
+
"pi-agent-doctor": "0.7.2",
|
|
28
|
+
"pi-agent-invariant": "0.7.2",
|
|
29
|
+
"pi-agent-search": "0.7.2",
|
|
30
|
+
"pi-agent-text": "0.7.2",
|
|
31
|
+
"pi-agent-text-editor": "0.7.2",
|
|
32
|
+
"pi-agent-tool-ui": "0.7.2"
|
|
33
33
|
},
|
|
34
34
|
"pi": {
|
|
35
35
|
"extensions": [
|
|
@@ -300,7 +300,7 @@ function formatSearchSession(
|
|
|
300
300
|
const heading = anchorsRegistered
|
|
301
301
|
? session.complete
|
|
302
302
|
? `SEARCH#${session.id}:all:line / SEARCH#${session.id}:all:match — ${summary}`
|
|
303
|
-
: `${summary} (
|
|
303
|
+
: `${summary} (incomplete results; no all anchors were registered)`
|
|
304
304
|
: `${summary} (files changed during search; results shown without anchors)`;
|
|
305
305
|
const lines = anchorsRegistered ? [SEARCH_ANCHOR_LEGEND, heading] : [heading];
|
|
306
306
|
const indices = new Map(session.matches.map((match, index) => [match, index + 1]));
|
|
@@ -340,6 +340,16 @@ function formatSearchSession(
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
const omittedFiles = fileCount - presentation.files.length;
|
|
344
|
+
if (omittedFiles > 0) {
|
|
345
|
+
const shownMatches = presentation.files.reduce(
|
|
346
|
+
(total, file) => total + (file.kind === "detailed" ? file.matches.length : file.matchCount),
|
|
347
|
+
0,
|
|
348
|
+
);
|
|
349
|
+
lines.push(
|
|
350
|
+
`\n… ${omittedFiles} more files (${count - shownMatches} matches) not displayed. Narrow path, include, or query to see them.`,
|
|
351
|
+
);
|
|
352
|
+
}
|
|
343
353
|
return lines.join("\n");
|
|
344
354
|
}
|
|
345
355
|
|
|
@@ -86,7 +86,7 @@ export async function runScopedSearch(
|
|
|
86
86
|
notices.push(
|
|
87
87
|
fallback.mode === "regex"
|
|
88
88
|
? "Search fallback: no literal matches; tried unquoted terms as regex."
|
|
89
|
-
: "Search fallback: no matches in earlier modes; tried separate words.",
|
|
89
|
+
: "Search fallback: no matches in earlier modes; tried separate words. Use these matches as location hints; refine the query before editing.",
|
|
90
90
|
);
|
|
91
91
|
} catch (error) {
|
|
92
92
|
if (
|
package/src/extensions/pi-agent-search/plugins/pi-agent-search-text/src/search-presentation.ts
CHANGED
|
@@ -23,7 +23,7 @@ export interface SearchPresentation {
|
|
|
23
23
|
readonly files: readonly SearchPresentationFile[];
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/** Shares one item budget between complete small files, compact summaries and groups. */
|
|
27
27
|
export function planSearchPresentation(
|
|
28
28
|
matches: readonly TextSearchMatch[],
|
|
29
29
|
detailBudget: number,
|
|
@@ -36,45 +36,55 @@ export function planSearchPresentation(
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const compacted = new Set<string>();
|
|
39
|
-
let
|
|
39
|
+
let itemCount = matches.length;
|
|
40
40
|
const noisiestFirst = [...bySource].sort(
|
|
41
41
|
([leftSource, left], [rightSource, right]) =>
|
|
42
42
|
right.length - left.length || leftSource.localeCompare(rightSource),
|
|
43
43
|
);
|
|
44
44
|
for (const [source, sourceMatches] of noisiestFirst) {
|
|
45
|
-
if (
|
|
45
|
+
if (itemCount <= detailBudget) break;
|
|
46
46
|
compacted.add(source);
|
|
47
|
-
|
|
47
|
+
itemCount -= sourceMatches.length - 1;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
const files = [
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
50
|
+
const files: SearchPresentationFile[] = [];
|
|
51
|
+
let remaining = detailBudget;
|
|
52
|
+
// Keep complete small files before spending the remaining budget on noisy summaries.
|
|
53
|
+
const ordered = [...bySource].sort(
|
|
54
|
+
([left], [right]) =>
|
|
55
|
+
Number(compacted.has(left)) - Number(compacted.has(right)) || left.localeCompare(right),
|
|
56
|
+
);
|
|
57
|
+
for (const [source, sourceMatches] of ordered) {
|
|
58
|
+
if (!compacted.has(source)) {
|
|
59
|
+
if (sourceMatches.length > remaining) continue;
|
|
60
|
+
files.push({ kind: "detailed", source, matches: sourceMatches });
|
|
61
|
+
remaining -= sourceMatches.length;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (remaining < 1) continue;
|
|
65
|
+
remaining--;
|
|
66
|
+
const counts = new Map<string, number>();
|
|
67
|
+
for (const match of sourceMatches)
|
|
68
|
+
counts.set(match.lineText, (counts.get(match.lineText) ?? 0) + 1);
|
|
69
|
+
const groups =
|
|
70
|
+
bySource.size === 1
|
|
71
|
+
? [...counts]
|
|
72
|
+
.sort(
|
|
73
|
+
([leftText, leftCount], [rightText, rightCount]) =>
|
|
74
|
+
rightCount - leftCount || leftText.localeCompare(rightText),
|
|
75
|
+
)
|
|
76
|
+
.slice(0, remaining)
|
|
77
|
+
.map(([text, matchCount]) => ({ text, matchCount }))
|
|
78
|
+
: [];
|
|
79
|
+
remaining -= groups.length;
|
|
80
|
+
files.push({
|
|
81
|
+
kind: "compacted",
|
|
82
|
+
source,
|
|
83
|
+
matchCount: sourceMatches.length,
|
|
84
|
+
uniqueLineCount: counts.size,
|
|
85
|
+
groups,
|
|
77
86
|
});
|
|
78
|
-
|
|
87
|
+
}
|
|
88
|
+
files.sort((left, right) => left.source.localeCompare(right.source));
|
|
79
89
|
return { files };
|
|
80
90
|
}
|
|
@@ -66,7 +66,7 @@ export async function runSearchRecipe(
|
|
|
66
66
|
notices.push(
|
|
67
67
|
fallback.mode === "regex"
|
|
68
68
|
? "Search fallback: no literal matches; tried unquoted terms as regex."
|
|
69
|
-
: "Search fallback: no matches in earlier modes; tried separate words.",
|
|
69
|
+
: "Search fallback: no matches in earlier modes; tried separate words. Use these matches as location hints; refine the query before editing.",
|
|
70
70
|
);
|
|
71
71
|
} catch (error) {
|
|
72
72
|
if (fallback.mode !== "regex" || !isRegexSyntaxError(error) || signal?.aborted) throw error;
|
|
@@ -146,6 +146,12 @@ function searchViewport(details: SearchToolDetails, expanded: boolean): readonly
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
if ((details.omittedFileCount ?? 0) > 0)
|
|
150
|
+
rows.push({
|
|
151
|
+
kind: "summary",
|
|
152
|
+
text: `… ${details.omittedFileCount} more files (${details.omittedMatchCount} matches) · narrow path, include, or query`,
|
|
153
|
+
});
|
|
154
|
+
|
|
149
155
|
if (details.fuzzy !== undefined || expanded || rows.length <= COMPACT_SEARCH_ROWS) {
|
|
150
156
|
return rows;
|
|
151
157
|
}
|
|
@@ -51,6 +51,9 @@ export interface SearchToolDetails {
|
|
|
51
51
|
readonly matchCount: number;
|
|
52
52
|
readonly fileCount: number;
|
|
53
53
|
readonly complete: boolean;
|
|
54
|
+
/** Files and matches retained internally but not shown within the item budget. */
|
|
55
|
+
readonly omittedFileCount?: number;
|
|
56
|
+
readonly omittedMatchCount?: number;
|
|
54
57
|
readonly files: readonly SearchResultFile[];
|
|
55
58
|
readonly fuzzy?: FuzzyResultData;
|
|
56
59
|
readonly fuzzyPresentation?: FuzzySearchPresentation;
|
|
@@ -71,6 +74,7 @@ export function createSearchToolDetails(
|
|
|
71
74
|
detailBudget = 50,
|
|
72
75
|
): SearchToolDetails {
|
|
73
76
|
const presentation = planSearchPresentation(matches, detailBudget);
|
|
77
|
+
const fileCount = new Set(matches.map((match) => match.source)).size;
|
|
74
78
|
const files = presentation.files.map((file): SearchResultFile =>
|
|
75
79
|
file.kind === "detailed"
|
|
76
80
|
? createSearchResultFile(file.source, file.matches, cwd)
|
|
@@ -88,7 +92,14 @@ export function createSearchToolDetails(
|
|
|
88
92
|
...(sessionId !== undefined && { sessionId }),
|
|
89
93
|
query,
|
|
90
94
|
matchCount: matches.length,
|
|
91
|
-
fileCount
|
|
95
|
+
fileCount,
|
|
96
|
+
...(presentation.files.length < fileCount
|
|
97
|
+
? {
|
|
98
|
+
omittedFileCount: fileCount - files.length,
|
|
99
|
+
omittedMatchCount:
|
|
100
|
+
matches.length - files.reduce((count, file) => count + file.matchCount, 0),
|
|
101
|
+
}
|
|
102
|
+
: {}),
|
|
92
103
|
complete,
|
|
93
104
|
files,
|
|
94
105
|
};
|
|
@@ -159,6 +170,8 @@ export function isSearchToolDetails(value: unknown): value is SearchToolDetails
|
|
|
159
170
|
typeof value.query !== "string" ||
|
|
160
171
|
!isCount(value.matchCount) ||
|
|
161
172
|
!isCount(value.fileCount) ||
|
|
173
|
+
(value.omittedFileCount !== undefined && !isCount(value.omittedFileCount)) ||
|
|
174
|
+
(value.omittedMatchCount !== undefined && !isCount(value.omittedMatchCount)) ||
|
|
162
175
|
typeof value.complete !== "boolean" ||
|
|
163
176
|
(value.sessionId !== undefined && typeof value.sessionId !== "string") ||
|
|
164
177
|
(value.fuzzy !== undefined && !isFuzzyResultData(value.fuzzy)) ||
|
|
@@ -171,8 +184,9 @@ export function isSearchToolDetails(value: unknown): value is SearchToolDetails
|
|
|
171
184
|
|
|
172
185
|
const files = value.files as readonly SearchResultFile[];
|
|
173
186
|
return (
|
|
174
|
-
value.fileCount === files.length &&
|
|
175
|
-
value.matchCount ===
|
|
187
|
+
value.fileCount === files.length + (value.omittedFileCount ?? 0) &&
|
|
188
|
+
value.matchCount ===
|
|
189
|
+
files.reduce((count, file) => count + file.matchCount, 0) + (value.omittedMatchCount ?? 0)
|
|
176
190
|
);
|
|
177
191
|
}
|
|
178
192
|
|
|
@@ -200,7 +200,11 @@ export function formatFuzzyCandidate(candidate: FuzzyCandidateData): string {
|
|
|
200
200
|
`Possible name: ${candidate.identifier} (${candidate.reason})`,
|
|
201
201
|
`${candidate.matchCount}${suffix} ${candidate.matchCount === 1 && candidate.selection.complete ? "match" : "matches"} in ${candidate.fileCount}${suffix} ${candidate.fileCount === 1 && candidate.selection.complete ? "file" : "files"}`,
|
|
202
202
|
`Exact alternative: ${JSON.stringify(candidate.identifier)} (case-sensitive, whole identifier)`,
|
|
203
|
-
...(candidate.selection.complete
|
|
203
|
+
...(candidate.selection.complete
|
|
204
|
+
? []
|
|
205
|
+
: [
|
|
206
|
+
"Capture limit reached; no complete all reference. Inspect the returned location; do not treat this candidate as a complete match set.",
|
|
207
|
+
]),
|
|
204
208
|
...(read
|
|
205
209
|
? [`Read: ${read}${reference || !first ? "" : ` · line ${first.range.startLine}`}`]
|
|
206
210
|
: []),
|
|
@@ -7,7 +7,7 @@ export const searchSchema = Type.Object(
|
|
|
7
7
|
query: Type.String({
|
|
8
8
|
minLength: 1,
|
|
9
9
|
description:
|
|
10
|
-
"Text to find
|
|
10
|
+
"Text to find or a Boolean expression. Quote text to keep it literal. Use regex:<pattern> for regular expressions, files:<pattern> for file paths, ast:<pattern> for syntax patterns, symbols:<query> for language symbols, or process:<query> for running processes.",
|
|
11
11
|
}),
|
|
12
12
|
path: Type.Optional({
|
|
13
13
|
...resultInputSchema,
|
|
@@ -28,7 +28,7 @@ export const searchSchema = Type.Object(
|
|
|
28
28
|
Type.Integer({
|
|
29
29
|
minimum: 1,
|
|
30
30
|
maximum: 1000,
|
|
31
|
-
description: "Maximum
|
|
31
|
+
description: "Maximum displayed items, including compact file summaries (default 50).",
|
|
32
32
|
}),
|
|
33
33
|
),
|
|
34
34
|
},
|
|
@@ -125,7 +125,8 @@ export default async function registerSearchCore(
|
|
|
125
125
|
openWorldHint: false,
|
|
126
126
|
},
|
|
127
127
|
label: "search",
|
|
128
|
-
description:
|
|
128
|
+
description:
|
|
129
|
+
"Use search to find text, file paths, syntax patterns, language symbols, web-page text, and running processes.",
|
|
129
130
|
promptSnippet:
|
|
130
131
|
"Search files and text with literals or regular expressions, plus syntax trees and language symbols",
|
|
131
132
|
get promptGuidelines(): string[] {
|