@xiaoso/dsh-tool-plus 0.1.7-beta.0 → 0.1.7
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/lib/index.mjs +11 -9
- package/lib/{scrapers-D8oWspgW.mjs → scrapers-CtQrQ5kG.mjs} +1 -1
- package/lib/types/client/BashPlusCard.d.ts +53 -0
- package/lib/types/client/ToolPlusSection.d.ts +36 -0
- package/lib/types/client/forms.d.ts +42 -0
- package/lib/types/client/index.d.ts +29 -0
- package/lib/types/client/locales.d.ts +19 -0
- package/lib/types/client/rm-safe-status-text.d.ts +15 -0
- package/lib/types/client/rows.d.ts +107 -0
- package/lib/types/client/web-connection-rpc.d.ts +22 -0
- package/lib/types/config/fields.d.ts +85 -0
- package/lib/types/config/omp-settings.d.ts +21 -0
- package/lib/types/config/settings.d.ts +212 -0
- package/lib/types/config/truncate.d.ts +27 -0
- package/lib/types/host/browser-probe-rpc.d.ts +29 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/tools/ast-edit/adapter/index.d.ts +26 -0
- package/lib/types/tools/ast-edit/adapter/sdk.d.ts +49 -0
- package/lib/types/tools/ast-grep/adapter/index.d.ts +31 -0
- package/lib/types/tools/ast-grep/adapter/sdk.d.ts +44 -0
- package/lib/types/tools/bash/adapter/spill.d.ts +34 -0
- package/lib/types/tools/bash/background.d.ts +40 -0
- package/lib/types/tools/bash/bash-executor.d.ts +102 -0
- package/lib/types/tools/bash/bash-interceptor.d.ts +33 -0
- package/lib/types/tools/bash/cd-workdir.d.ts +35 -0
- package/lib/types/tools/bash/logger.d.ts +18 -0
- package/lib/types/tools/bash/non-interactive-env.d.ts +5 -0
- package/lib/types/tools/bash/render.d.ts +46 -0
- package/lib/types/tools/bash/rm-safe-status.d.ts +62 -0
- package/lib/types/tools/bash/rm-safe.d.ts +18 -0
- package/lib/types/tools/bash/sanitize-text.d.ts +34 -0
- package/lib/types/tools/bash/shell-snapshot.d.ts +31 -0
- package/lib/types/tools/bash/shell-tokenize.d.ts +60 -0
- package/lib/types/tools/bash/streaming-output.d.ts +32 -0
- package/lib/types/tools/bash/trash-cli-main.d.ts +1 -0
- package/lib/types/tools/bash/trash-cli.d.ts +77 -0
- package/lib/types/tools/bash/types.d.ts +107 -0
- package/lib/types/tools/bash/which.d.ts +20 -0
- package/lib/types/tools/bash/windows-shell.d.ts +31 -0
- package/lib/types/tools/bash/yield.d.ts +71 -0
- package/lib/types/tools/edit/adapter/index.d.ts +57 -0
- package/lib/types/tools/edit/adapter/tools/auto-generated-guard.d.ts +10 -0
- package/lib/types/tools/edit/adapter/tools/output-meta.d.ts +34 -0
- package/lib/types/tools/edit/adapter/tools/plan-mode-guard.d.ts +21 -0
- package/lib/types/tools/glob/adapter/index.d.ts +52 -0
- package/lib/types/tools/grep/adapter/index.d.ts +53 -0
- package/lib/types/tools/grep/adapter/match-path.d.ts +1 -0
- package/lib/types/tools/hashline/native/diff-preview.d.ts +37 -0
- package/lib/types/tools/hashline/native/index.d.ts +109 -0
- package/lib/types/tools/hashline/native/normalize.d.ts +29 -0
- package/lib/types/tools/hashline/native/policy.d.ts +98 -0
- package/lib/types/tools/hashline/native/writer.d.ts +42 -0
- package/lib/types/tools/omp/browser/launch.d.ts +28 -0
- package/lib/types/tools/omp/browser/readable.d.ts +17 -0
- package/lib/types/tools/omp/config/settings-schema.d.ts +12 -0
- package/lib/types/tools/omp/config/settings.d.ts +59 -0
- package/lib/types/tools/omp/edit/apply-patch/parser.d.ts +34 -0
- package/lib/types/tools/omp/edit/details.d.ts +54 -0
- package/lib/types/tools/omp/edit/diff.d.ts +60 -0
- package/lib/types/tools/omp/edit/dispatch.d.ts +43 -0
- package/lib/types/tools/omp/edit/file-snapshot-store.d.ts +81 -0
- package/lib/types/tools/omp/edit/hashline/execute.d.ts +40 -0
- package/lib/types/tools/omp/edit/hashline/params.d.ts +6 -0
- package/lib/types/tools/omp/edit/modes/apply-patch.d.ts +25 -0
- package/lib/types/tools/omp/edit/modes/patch.d.ts +109 -0
- package/lib/types/tools/omp/edit/modes/replace.d.ts +151 -0
- package/lib/types/tools/omp/edit/normalize.d.ts +31 -0
- package/lib/types/tools/omp/edit/notebook.d.ts +50 -0
- package/lib/types/tools/omp/edit/read-file.d.ts +2 -0
- package/lib/types/tools/omp/edit/snapshot-details.d.ts +33 -0
- package/lib/types/tools/omp/extensibility/skills.d.ts +22 -0
- package/lib/types/tools/omp/internal-urls/index.d.ts +100 -0
- package/lib/types/tools/omp/internal-urls/local-protocol.d.ts +12 -0
- package/lib/types/tools/omp/internal-urls/parse.d.ts +31 -0
- package/lib/types/tools/omp/internal-urls/types.d.ts +189 -0
- package/lib/types/tools/omp/internal-urls/xd-protocol.d.ts +19 -0
- package/lib/types/tools/omp/markit/converters/docx.d.ts +6 -0
- package/lib/types/tools/omp/markit/converters/epub.d.ts +15 -0
- package/lib/types/tools/omp/markit/converters/pdf/index.d.ts +7 -0
- package/lib/types/tools/omp/markit/converters/pptx.d.ts +57 -0
- package/lib/types/tools/omp/markit/converters/xlsx.d.ts +25 -0
- package/lib/types/tools/omp/markit/index.d.ts +2 -0
- package/lib/types/tools/omp/markit/registry.d.ts +16 -0
- package/lib/types/tools/omp/markit/types.d.ts +30 -0
- package/lib/types/tools/omp/sdk.d.ts +103 -0
- package/lib/types/tools/omp/session/agent-storage.d.ts +154 -0
- package/lib/types/tools/omp/session/streaming-output.d.ts +244 -0
- package/lib/types/tools/omp/task/spawn-policy.d.ts +22 -0
- package/lib/types/tools/omp/tools/approval.d.ts +62 -0
- package/lib/types/tools/omp/tools/ast-edit.d.ts +73 -0
- package/lib/types/tools/omp/tools/ast-grep.d.ts +61 -0
- package/lib/types/tools/omp/tools/auto-generated-guard.d.ts +20 -0
- package/lib/types/tools/omp/tools/conflict-detect.d.ts +237 -0
- package/lib/types/tools/omp/tools/fetch.d.ts +103 -0
- package/lib/types/tools/omp/tools/file-recorder.d.ts +13 -0
- package/lib/types/tools/omp/tools/fs-cache-invalidation.d.ts +15 -0
- package/lib/types/tools/omp/tools/glob.d.ts +86 -0
- package/lib/types/tools/omp/tools/grep.d.ts +102 -0
- package/lib/types/tools/omp/tools/grouped-file-output.d.ts +70 -0
- package/lib/types/tools/omp/tools/index.d.ts +23 -0
- package/lib/types/tools/omp/tools/list-limit.d.ts +12 -0
- package/lib/types/tools/omp/tools/match-line-format.d.ts +11 -0
- package/lib/types/tools/omp/tools/output-meta.d.ts +160 -0
- package/lib/types/tools/omp/tools/path-utils.d.ts +326 -0
- package/lib/types/tools/omp/tools/plan-mode-guard.d.ts +33 -0
- package/lib/types/tools/omp/tools/read-archive.d.ts +16 -0
- package/lib/types/tools/omp/tools/read-format.d.ts +104 -0
- package/lib/types/tools/omp/tools/read-path-resolution.d.ts +19 -0
- package/lib/types/tools/omp/tools/read-selector.d.ts +27 -0
- package/lib/types/tools/omp/tools/read-sqlite.d.ts +16 -0
- package/lib/types/tools/omp/tools/read-summary.d.ts +15 -0
- package/lib/types/tools/omp/tools/read.d.ts +70 -0
- package/lib/types/tools/omp/tools/render-utils.d.ts +28 -0
- package/lib/types/tools/omp/tools/report-tool-issue.d.ts +149 -0
- package/lib/types/tools/omp/tools/resolve.d.ts +127 -0
- package/lib/types/tools/omp/tools/sqlite-reader.d.ts +114 -0
- package/lib/types/tools/omp/tools/tool-errors.d.ts +33 -0
- package/lib/types/tools/omp/tools/tool-result.d.ts +33 -0
- package/lib/types/tools/omp/tools/tool-timeouts.d.ts +57 -0
- package/lib/types/tools/omp/tools/write.d.ts +53 -0
- package/lib/types/tools/omp/tools/writethrough.d.ts +24 -0
- package/lib/types/tools/omp/utils/block-context.d.ts +35 -0
- package/lib/types/tools/omp/utils/cpuprofile.d.ts +51 -0
- package/lib/types/tools/omp/utils/edit-mode.d.ts +13 -0
- package/lib/types/tools/omp/utils/file-display-mode.d.ts +27 -0
- package/lib/types/tools/omp/utils/image-loading.d.ts +51 -0
- package/lib/types/tools/omp/utils/image-resize.d.ts +42 -0
- package/lib/types/tools/omp/utils/lang-from-path.d.ts +9 -0
- package/lib/types/tools/omp/utils/markit-cache.d.ts +23 -0
- package/lib/types/tools/omp/utils/markit.d.ts +30 -0
- package/lib/types/tools/omp/utils/profile-tree.d.ts +47 -0
- package/lib/types/tools/omp/utils/sample-profile.d.ts +67 -0
- package/lib/types/tools/omp/utils/sixel.d.ts +21 -0
- package/lib/types/tools/omp/utils/tools-manager.d.ts +11 -0
- package/lib/types/tools/omp/utils/turndown.d.ts +15 -0
- package/lib/types/tools/omp/utils/zip.d.ts +129 -0
- package/lib/types/tools/omp/web/browser-render.d.ts +50 -0
- package/lib/types/tools/omp/web/parallel.d.ts +68 -0
- package/lib/types/tools/omp/web/scrapers/artifacthub.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/arxiv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/aur.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/biorxiv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/bluesky.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/brew.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/cheatsh.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/chocolatey.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/choosealicense.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/cisa-kev.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/clojars.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/coingecko.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/crates-io.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/crossref.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/devto.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/discogs.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/discourse.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/dockerhub.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/docs-rs.d.ts +9 -0
- package/lib/types/tools/omp/web/scrapers/fdroid.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/firefox-addons.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/flathub.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/github-gist.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/github.d.ts +34 -0
- package/lib/types/tools/omp/web/scrapers/gitlab.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/go-pkg.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/hackage.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/hackernews.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/hex.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/huggingface.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/iacr.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/index.d.ts +84 -0
- package/lib/types/tools/omp/web/scrapers/jetbrains-marketplace.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/lemmy.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/lobsters.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/mastodon.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/maven.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/mdn.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/metacpan.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/musicbrainz.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/npm.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/nuget.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/nvd.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/ollama.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/open-vsx.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/opencorporates.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/openlibrary.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/orcid.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/osv.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/packagist.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pub-dev.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pubmed.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/pypi.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rawg.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/readthedocs.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/reddit.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/repology.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rfc.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/rubygems.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/searchcode.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/sec-edgar.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/semantic-scholar.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/snapcraft.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/sourcegraph.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/spdx.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/spotify.d.ts +8 -0
- package/lib/types/tools/omp/web/scrapers/stackoverflow.d.ts +6 -0
- package/lib/types/tools/omp/web/scrapers/terraform.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/tldr.d.ts +7 -0
- package/lib/types/tools/omp/web/scrapers/twitter.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/types.d.ts +90 -0
- package/lib/types/tools/omp/web/scrapers/utils.d.ts +26 -0
- package/lib/types/tools/omp/web/scrapers/vimeo.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/vscode-marketplace.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/w3c.d.ts +2 -0
- package/lib/types/tools/omp/web/scrapers/wikidata.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/wikipedia.d.ts +5 -0
- package/lib/types/tools/omp/web/scrapers/youtube.d.ts +5 -0
- package/lib/types/tools/omp/web/search/providers/utils.d.ts +49 -0
- package/lib/types/tools/omp/web/search/types.d.ts +501 -0
- package/lib/types/tools/omp/web/search/utils.d.ts +4 -0
- package/lib/types/tools/omp/workspace-tree.d.ts +42 -0
- package/lib/types/tools/read/adapter/index.d.ts +49 -0
- package/lib/types/tools/read/adapter/internal-urls/artifact-protocol.d.ts +15 -0
- package/lib/types/tools/read/adapter/internal-urls/registry-helpers.d.ts +44 -0
- package/lib/types/tools/read/adapter/registry/agent-registry.d.ts +29 -0
- package/lib/types/tools/shared/auto-generated-guard.dsh.d.ts +16 -0
- package/lib/types/tools/shared/browser-detect.d.ts +54 -0
- package/lib/types/tools/shared/browser-rpc-channel.d.ts +40 -0
- package/lib/types/tools/shared/bun-ffi-shim.d.ts +13 -0
- package/lib/types/tools/shared/bun-named-shim.d.ts +42 -0
- package/lib/types/tools/shared/bun-shim.d.ts +138 -0
- package/lib/types/tools/shared/bun-sqlite-shim.d.ts +49 -0
- package/lib/types/tools/shared/fs-promises-shim.d.ts +15 -0
- package/lib/types/tools/shared/image-bridge.d.ts +98 -0
- package/lib/types/tools/shared/omp-prompt.d.ts +47 -0
- package/lib/types/tools/shared/sandbox-policy.d.ts +38 -0
- package/lib/types/tools/shared/session-state.d.ts +51 -0
- package/lib/types/tools/shared/tool-errors.d.ts +33 -0
- package/lib/types/tools/shared/win-path-fixes.d.ts +16 -0
- package/lib/types/tools/write/adapter/index.d.ts +31 -0
- package/lib/{utils-CCfhUQen.mjs → utils-ECAwvaPQ.mjs} +1 -1
- package/package.json +2 -2
- package/presets/package.json +1 -1
- package/scripts/patch-pi-natives.mjs +108 -108
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
import type { Skill } from "../extensibility/skills";
|
|
2
|
+
import { type LocalProtocolOptions } from "../internal-urls";
|
|
3
|
+
export declare function expandTilde(filePath: string, home?: string): string;
|
|
4
|
+
export declare function expandPath(filePath: string): string;
|
|
5
|
+
export declare function normalizeWindowsDriveAliasPath(filePath: string, platform?: NodeJS.Platform): string;
|
|
6
|
+
/**
|
|
7
|
+
* Inclusive line range describing one selector segment (e.g. `50-100`,
|
|
8
|
+
* `301-`, or `50+10`). `endLine` is `undefined` for open-ended ranges.
|
|
9
|
+
*/
|
|
10
|
+
export interface LineRange {
|
|
11
|
+
startLine: number;
|
|
12
|
+
endLine: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Parse a single `N`, `N-M`, `N-`, `N+K`, or `..`-aliased (`N..M`, `N..`) chunk. Throws via {@link ToolError} on invalid bounds. */
|
|
15
|
+
export declare function parseLineRangeChunk(sel: string): LineRange | null;
|
|
16
|
+
/**
|
|
17
|
+
* Parse a comma-separated list of line ranges (e.g. `5-16,960-973`). Returns
|
|
18
|
+
* the ranges in ascending order with overlapping/adjacent ranges merged so
|
|
19
|
+
* downstream consumers can stream the file in a single forward pass per range.
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseLineRanges(sel: string): [LineRange, ...LineRange[]] | null;
|
|
22
|
+
/**
|
|
23
|
+
* Extract the line-range component from a read-tool selector that may also
|
|
24
|
+
* carry a verbatim/index display mode (`raw`, `conflicts`) — alone or compounded
|
|
25
|
+
* with a range (`raw:50-100`, `50-100:raw`). Returns the parsed ranges when the
|
|
26
|
+
* selector names any, otherwise `undefined` (pure `raw`/`conflicts`/none).
|
|
27
|
+
*
|
|
28
|
+
* Used by content search, which honors line ranges as a match filter but has no
|
|
29
|
+
* use for verbatim/conflict display modes — so those selectors are accepted and
|
|
30
|
+
* treated as an unfiltered, whole-resource search rather than rejected.
|
|
31
|
+
*/
|
|
32
|
+
export declare function selectorLineRanges(sel: string | undefined): [LineRange, ...LineRange[]] | undefined;
|
|
33
|
+
/** Return `true` when `lineNumber` (1-indexed) falls in any of the supplied ranges. */
|
|
34
|
+
export declare function isLineInRanges(lineNumber: number, ranges: readonly LineRange[]): boolean;
|
|
35
|
+
export declare function splitPathAndSel(rawPath: string): {
|
|
36
|
+
path: string;
|
|
37
|
+
sel?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Three-way probe for whether the exact filesystem entry named by `filePath`
|
|
41
|
+
* exists. `stat` (used earlier) failed for reasons other than "no such file"
|
|
42
|
+
* (dangling symlink, `EACCES` on a parent, transient I/O), and each of those
|
|
43
|
+
* silently reinterpreted a real literal path such as `test:1-2` as `test`
|
|
44
|
+
* plus selector `1-2` (issue #4618). `lstat` inspects the entry itself, so a
|
|
45
|
+
* dangling symlink is still detected as present; ambiguous errors resolve to
|
|
46
|
+
* `"unknown"` so callers keep the raw path instead of guessing.
|
|
47
|
+
*
|
|
48
|
+
* `ENAMETOOLONG` resolves to `"missing"` rather than `"unknown"`: a path whose
|
|
49
|
+
* component or whole length exceeds the OS limit can never name a real single
|
|
50
|
+
* entry, so it is strictly stronger evidence of non-existence than `ENOENT`.
|
|
51
|
+
* Without this, a semicolon-joined `path` list long enough to trip the limit
|
|
52
|
+
* (bare filenames past `NAME_MAX`, or a total past `PATH_MAX`) was read as one
|
|
53
|
+
* literal path and the delimited split was suppressed (issue #7597).
|
|
54
|
+
*/
|
|
55
|
+
export declare function probeLiteralPathExists(filePath: string, cwd: string): Promise<"exists" | "missing" | "unknown">;
|
|
56
|
+
/**
|
|
57
|
+
* Async sibling of {@link splitPathAndSel} that prefers a literal filesystem
|
|
58
|
+
* path over selector interpretation. Filenames whose tail matches the selector
|
|
59
|
+
* grammar (e.g. `test:1-2`, `log:raw`) are legal on POSIX; without this the
|
|
60
|
+
* strict splitter peels the tail and both `read` and `grep` refuse to open the
|
|
61
|
+
* real file (issue #4618). The literal wins on a confirmed `lstat`, and also
|
|
62
|
+
* on `"unknown"` (`EACCES` on a parent, transient I/O), so an unreachable
|
|
63
|
+
* literal is never silently reinterpreted as `path + selector`. Only a
|
|
64
|
+
* definitive `ENOENT`/`ENOTDIR` falls back to the strict split.
|
|
65
|
+
*/
|
|
66
|
+
export declare function splitPathAndSelPreferringLiteral(rawPath: string, cwd: string): Promise<{
|
|
67
|
+
path: string;
|
|
68
|
+
sel?: string;
|
|
69
|
+
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Variant of {@link splitPathAndSel} for internal URLs (`scheme://...`).
|
|
72
|
+
*
|
|
73
|
+
* The filesystem-path splitter is intentionally conservative: it refuses to
|
|
74
|
+
* peel a trailing `:<chunk>` unless that chunk matches the strict selector
|
|
75
|
+
* grammar. That rule is right for filesystem paths (a file named `a:1-50` is
|
|
76
|
+
* legal) but wrong for internal URLs, where any trailing `:<chunk>` after the
|
|
77
|
+
* scheme is unambiguously a read-tool selector — even if malformed (e.g.
|
|
78
|
+
* `artifact://3:raw:-100`).
|
|
79
|
+
*
|
|
80
|
+
* This function iteratively peels selector-shaped chunks (well-formed plus
|
|
81
|
+
* common malformed shapes like `:-N`) so the rest of the read tool can pass a
|
|
82
|
+
* clean URL to the protocol handler and surface selector errors via parseSel
|
|
83
|
+
* instead of as misleading "host invalid" errors from the handler. Schemes
|
|
84
|
+
* whose resource URIs may legitimately contain colons (`mcp://`) are skipped.
|
|
85
|
+
*
|
|
86
|
+
* Falls back to the input unchanged when nothing matches.
|
|
87
|
+
*/
|
|
88
|
+
export declare function splitInternalUrlSel(rawPath: string): {
|
|
89
|
+
path: string;
|
|
90
|
+
sel?: string;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Peel a read-tool selector off an internal-URL write target so `write` resolves
|
|
94
|
+
* the same file `read` does (e.g. `ssh://h/f:raw` -> `ssh://h/f`). Only the
|
|
95
|
+
* whole-file display modes `raw`/`conflicts` are accepted (they do not change
|
|
96
|
+
* which bytes are written); any other selector-shaped tail `splitInternalUrlSel`
|
|
97
|
+
* peels — a line range, a compound like `raw:1-20`, or a malformed `:-N` — throws,
|
|
98
|
+
* because `write` addresses a whole file, not a partial range, and silently
|
|
99
|
+
* stripping it would write to a path the caller never named. Non-URL paths and
|
|
100
|
+
* URLs without a selector pass through unchanged.
|
|
101
|
+
*/
|
|
102
|
+
export declare function peelWriteUrlSelector(rawPath: string): string;
|
|
103
|
+
export declare function normalizeLocalScheme(filePath: string): string;
|
|
104
|
+
export declare function isInternalUrlPath(filePath: string): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* True when a tool path argument references the `ssh://` scheme anywhere.
|
|
107
|
+
*
|
|
108
|
+
* Substring (not anchored) on purpose: it feeds the read/search/write approval
|
|
109
|
+
* tier, which runs synchronously on the raw args. `search` only flattens a
|
|
110
|
+
* delimited `paths: "a,ssh://h/x"` into separate entries *after* approval, so an
|
|
111
|
+
* anchored check would let an embedded `ssh://` slip through at the read tier.
|
|
112
|
+
* Matching the literal `ssh://` substring also tracks exactly what routes to the
|
|
113
|
+
* SSH handler; over-matching only over-prompts (fail-closed).
|
|
114
|
+
*/
|
|
115
|
+
export declare function pathTargetsSsh(path: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* True when a path is specifically an `ssh://` URL (anchored scheme match).
|
|
118
|
+
* Unlike {@link pathTargetsSsh} (substring, for the pre-expansion approval
|
|
119
|
+
* scan), this is the exact per-entry check used to reject `ssh://` *before* a
|
|
120
|
+
* side-effecting `InternalUrlRouter.resolve` in tools that need a local file.
|
|
121
|
+
*/
|
|
122
|
+
export declare function isSshUrl(path: string): boolean;
|
|
123
|
+
/**
|
|
124
|
+
* True when the read tool's URL parser (`parseReadUrlTarget` in fetch.ts) would
|
|
125
|
+
* recognize this path as a readable external URL: a strict `http(s)://`, a
|
|
126
|
+
* collapsed `http(s):/host` (Node path normalization folds `//` → `/`), or a
|
|
127
|
+
* scheme-less `www.` spelling. Keep in sync with `parseReadUrlTarget`.
|
|
128
|
+
*/
|
|
129
|
+
export declare function isReadableUrlPath(value: string): boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Resolve a path relative to the given cwd.
|
|
132
|
+
* Handles ~ expansion and absolute paths.
|
|
133
|
+
*
|
|
134
|
+
* A bare root slash is treated as a workspace-root alias for tool inputs. Users
|
|
135
|
+
* often pass `/` to mean “search from here”, and letting tools escape to the
|
|
136
|
+
* filesystem root is almost never what they intended.
|
|
137
|
+
*/
|
|
138
|
+
export declare function resolveToCwd(filePath: string, cwd: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Resolve a path that MUST stay inside `cwd`, or `null` when it would escape.
|
|
141
|
+
*
|
|
142
|
+
* {@link resolveToCwd} deliberately honors absolute paths, `~`, and `..` —
|
|
143
|
+
* correct for a path a user typed, wrong for one a remote peer supplied.
|
|
144
|
+
* Callers handling untrusted input (Cursor's `download_path`) use this instead:
|
|
145
|
+
* only a non-empty relative path landing under the live cwd is accepted, so
|
|
146
|
+
* neither `/etc/passwd` nor `../../escape` can be written through.
|
|
147
|
+
*
|
|
148
|
+
* The lexical check alone is not containment: a symlink inside the workspace
|
|
149
|
+
* can point anywhere, so `out/config` under a `ws/out -> /elsewhere` link is
|
|
150
|
+
* relative, `..`-free, and still writes outside. Both the target and its
|
|
151
|
+
* deepest existing ancestor are therefore realpath-resolved — the ancestor
|
|
152
|
+
* because a download names a file that does not exist yet, so the link in its
|
|
153
|
+
* path is the only thing that can be resolved before the write.
|
|
154
|
+
*
|
|
155
|
+
* The cwd itself is rejected: a download names a file, never the directory.
|
|
156
|
+
*/
|
|
157
|
+
export declare function confineToWorkspace(filePath: string, cwd: string): string | null;
|
|
158
|
+
export declare function formatPathRelativeToCwd(filePath: string, cwd: string, options?: {
|
|
159
|
+
trailingSlash?: boolean;
|
|
160
|
+
}): string;
|
|
161
|
+
/**
|
|
162
|
+
* Strip matching surrounding double quotes from a path string.
|
|
163
|
+
* Common when users paste quoted paths from Windows Explorer or shell copy-paste.
|
|
164
|
+
* Only double quotes — single quotes are valid POSIX filename characters.
|
|
165
|
+
* Tradeoff: a POSIX path literally starting AND ending with " would also be unquoted.
|
|
166
|
+
* Accepted because such names are virtually nonexistent in practice.
|
|
167
|
+
*/
|
|
168
|
+
export declare function stripOuterDoubleQuotes(input: string): string;
|
|
169
|
+
export declare function normalizePathLikeInput(input: string): string;
|
|
170
|
+
/**
|
|
171
|
+
* Normalize a path argument that may arrive as a single string, a JSON-encoded
|
|
172
|
+
* string array (`'["a.ts"]'`), or an actual array into a flat `string[]`.
|
|
173
|
+
* Delimited single strings (`"a.ts b.ts"`) are left for
|
|
174
|
+
* {@link expandDelimitedPathEntries} to split.
|
|
175
|
+
*/
|
|
176
|
+
export declare function toPathList(input: string | string[] | undefined): string[];
|
|
177
|
+
export declare function hasGlobPathChars(filePath: string): boolean;
|
|
178
|
+
type PathEntrySplitter = (item: string) => {
|
|
179
|
+
basePath: string;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Split one path-like entry whose multiple targets were flattened into one
|
|
183
|
+
* string. Existing paths are kept intact, so real filenames containing spaces,
|
|
184
|
+
* commas, or semicolons win over delimiter recovery.
|
|
185
|
+
*/
|
|
186
|
+
export declare function splitDelimitedPathEntry(entry: string, cwd: string, options?: {
|
|
187
|
+
splitter?: PathEntrySplitter;
|
|
188
|
+
routedUrlPredicate?: (entry: string) => boolean;
|
|
189
|
+
}): Promise<string[] | null>;
|
|
190
|
+
/** Expand delimited entries in-place while preserving unsplit entries. */
|
|
191
|
+
export declare function expandDelimitedPathEntries(entries: readonly string[], cwd: string, options?: {
|
|
192
|
+
splitter?: PathEntrySplitter;
|
|
193
|
+
}): Promise<string[]>;
|
|
194
|
+
export interface ParsedSearchPath {
|
|
195
|
+
basePath: string;
|
|
196
|
+
glob?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface ParsedFindPattern {
|
|
199
|
+
basePath: string;
|
|
200
|
+
globPattern: string;
|
|
201
|
+
hasGlob: boolean;
|
|
202
|
+
}
|
|
203
|
+
export interface ResolvedSearchTarget {
|
|
204
|
+
basePath: string;
|
|
205
|
+
glob?: string;
|
|
206
|
+
}
|
|
207
|
+
export interface ResolvedMultiSearchPath {
|
|
208
|
+
basePath: string;
|
|
209
|
+
glob?: string;
|
|
210
|
+
scopePath: string;
|
|
211
|
+
exactFilePaths?: string[];
|
|
212
|
+
targets?: ResolvedSearchTarget[];
|
|
213
|
+
}
|
|
214
|
+
export interface ResolvedFindTarget {
|
|
215
|
+
basePath: string;
|
|
216
|
+
globPattern: string;
|
|
217
|
+
hasGlob: boolean;
|
|
218
|
+
}
|
|
219
|
+
export interface ResolvedMultiFindPattern {
|
|
220
|
+
targets: ResolvedFindTarget[];
|
|
221
|
+
scopePath: string;
|
|
222
|
+
}
|
|
223
|
+
export declare function parseSearchPath(filePath: string): ParsedSearchPath;
|
|
224
|
+
/**
|
|
225
|
+
* Async sibling of {@link parseSearchPath} that prefers literal interpretation
|
|
226
|
+
* when a path containing glob metacharacters resolves to an existing entry on
|
|
227
|
+
* disk. Disambiguates Next.js/SvelteKit routes like `apps/[id]/page.tsx` —
|
|
228
|
+
* without this, `[id]` is parsed as a glob character class and silently
|
|
229
|
+
* matches nothing.
|
|
230
|
+
*/
|
|
231
|
+
export declare function parseSearchPathPreferringLiteral(filePath: string, cwd: string): Promise<ParsedSearchPath>;
|
|
232
|
+
export declare function parseFindPattern(pattern: string): ParsedFindPattern;
|
|
233
|
+
export declare function combineSearchGlobs(prefixGlob?: string, suffixGlob?: string): string | undefined;
|
|
234
|
+
export declare function resolveExplicitSearchPaths(pathItems: string[], cwd: string, suffixGlob?: string, fanOutFileItems?: boolean): Promise<ResolvedMultiSearchPath | undefined>;
|
|
235
|
+
export declare function resolveExplicitFindPatterns(patternItems: string[], cwd: string): Promise<ResolvedMultiFindPattern | undefined>;
|
|
236
|
+
/**
|
|
237
|
+
* Result of partitioning a list of user-supplied paths/globs into entries whose
|
|
238
|
+
* base directory currently exists on disk versus those that do not.
|
|
239
|
+
*
|
|
240
|
+
* Used by multi-path tools (search, find, ast_grep, ast_edit) to tolerate one
|
|
241
|
+
* or more missing entries in a multi-path call: the surviving entries should
|
|
242
|
+
* still be searched, with the missing entries surfaced as a non-fatal warning.
|
|
243
|
+
*/
|
|
244
|
+
export interface PartitionedPaths {
|
|
245
|
+
/** Raw input strings whose resolved base path exists. */
|
|
246
|
+
valid: string[];
|
|
247
|
+
/** Raw input strings whose resolved base path is missing (ENOENT). */
|
|
248
|
+
missing: string[];
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Stat each input's base path concurrently; return entries split by existence.
|
|
252
|
+
*
|
|
253
|
+
* `splitter` is expected to be {@link parseFindPattern} or
|
|
254
|
+
* {@link parseSearchPath}: both return a `basePath` field that this helper
|
|
255
|
+
* resolves against `cwd` and stats. ENOENT is the only swallowed error — every
|
|
256
|
+
* other stat failure (permission, IO, etc.) propagates so callers do not silently
|
|
257
|
+
* skip paths that exist but are unreadable.
|
|
258
|
+
*
|
|
259
|
+
* Order of `valid` and `missing` follows the input order, so callers can rely
|
|
260
|
+
* on `valid[0]` matching the first surviving user-supplied entry.
|
|
261
|
+
*/
|
|
262
|
+
export declare function partitionExistingPaths(items: string[], cwd: string, splitter: (item: string) => {
|
|
263
|
+
basePath: string;
|
|
264
|
+
}): Promise<PartitionedPaths>;
|
|
265
|
+
export declare function resolveReadPath(filePath: string, cwd: string): string;
|
|
266
|
+
/**
|
|
267
|
+
* Find a unique workspace entry whose trailing path matches a missing authored path.
|
|
268
|
+
* Returns `null` for no match, ambiguity, timeout, or scan failure.
|
|
269
|
+
*/
|
|
270
|
+
export declare function findUniqueWorkspaceSuffix(rawPath: string, cwd: string, signal?: AbortSignal): Promise<{
|
|
271
|
+
absolutePath: string;
|
|
272
|
+
displayPath: string;
|
|
273
|
+
} | null>;
|
|
274
|
+
/** Local file materialized from a readable external URL for shared tool-scope resolution. */
|
|
275
|
+
export interface ResolvedExternalSearchUrl {
|
|
276
|
+
/** Absolute or cwd-relative file path to search. */
|
|
277
|
+
sourcePath: string;
|
|
278
|
+
/** True when the materialized file must not mint editable anchors. */
|
|
279
|
+
immutable?: boolean;
|
|
280
|
+
}
|
|
281
|
+
export interface ToolScopeOptions {
|
|
282
|
+
rawPaths: string[];
|
|
283
|
+
cwd: string;
|
|
284
|
+
/** Verb used in the "Cannot {action} internal URL without a backing file: …" message. */
|
|
285
|
+
internalUrlAction: string;
|
|
286
|
+
/** Collect absolute paths flagged immutable by their internal-URL handler. */
|
|
287
|
+
trackImmutableSources?: boolean;
|
|
288
|
+
/** Honor `exactFilePaths` from {@link resolveExplicitSearchPaths} (search-only). */
|
|
289
|
+
surfaceExactFilePaths?: boolean;
|
|
290
|
+
/** Fan plain-file entries out into per-target scans instead of folding them
|
|
291
|
+
* into a directory walk's glob union (search-only: the caller must dedupe
|
|
292
|
+
* matches from overlapping targets). */
|
|
293
|
+
fanOutFileTargets?: boolean;
|
|
294
|
+
/** Extra hint appended to "Path not found" when stat fails and the user supplied multiple paths. */
|
|
295
|
+
multipathStatHint?: string;
|
|
296
|
+
/** Calling session's settings — forwarded to the internal-URL router so caller-aware handlers (issue://, pr://) honor it. */
|
|
297
|
+
settings?: unknown;
|
|
298
|
+
/** Caller's abort signal — forwarded to the internal-URL router. */
|
|
299
|
+
signal?: AbortSignal;
|
|
300
|
+
/** Calling session's `local://` root mapping — pins resolutions to the calling session. */
|
|
301
|
+
localProtocolOptions?: LocalProtocolOptions;
|
|
302
|
+
/** Calling session's loaded skills — lets skill:// resolve without process-global state. */
|
|
303
|
+
skills?: readonly Skill[];
|
|
304
|
+
/** Materialize readable external URLs to local text files before scope derivation. */
|
|
305
|
+
resolveExternalUrl?: (rawPath: string) => Promise<ResolvedExternalSearchUrl | undefined>;
|
|
306
|
+
}
|
|
307
|
+
export interface ToolScopeResolution {
|
|
308
|
+
searchPath: string;
|
|
309
|
+
scopePath: string;
|
|
310
|
+
globFilter: string | undefined;
|
|
311
|
+
isDirectory: boolean;
|
|
312
|
+
multiTargets?: ResolvedSearchTarget[];
|
|
313
|
+
exactFilePaths?: string[];
|
|
314
|
+
missingPaths: string[];
|
|
315
|
+
immutableSourcePaths: Set<string>;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Shared path-input pipeline for `search`, `ast_grep`, and `ast_edit`:
|
|
319
|
+
* 1. normalize + reject empty paths,
|
|
320
|
+
* 2. resolve internal URLs through {@link InternalUrlRouter} to backing files,
|
|
321
|
+
* 3. partition existing vs missing when multiple paths are supplied,
|
|
322
|
+
* 4. derive a single search base path / glob, or a multi-target list,
|
|
323
|
+
* 5. stat the resolved base path so callers can branch on directory vs file scope.
|
|
324
|
+
*/
|
|
325
|
+
export declare function resolveToolSearchScope(opts: ToolScopeOptions): Promise<ToolScopeResolution>;
|
|
326
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ToolSession } from "../../omp/tools/index.ts";
|
|
2
|
+
/** Strip the hashline `[path#TAG]` wrapper from a write/edit target so the inner
|
|
3
|
+
* filesystem path drives both authorization and resolution. Only unwraps inputs
|
|
4
|
+
* that match the strict hashline header shape (`[path]` or `[path#XXXX]` with a
|
|
5
|
+
* 4-hex tag); anything else returns the original string so the downstream
|
|
6
|
+
* resolver surfaces the real error. Exported for callers (e.g. `write`) that
|
|
7
|
+
* make scheme/bridge-routing decisions before {@link resolvePlanPath} runs. */
|
|
8
|
+
export declare function unwrapHashlineHeaderPath(targetPath: string): string;
|
|
9
|
+
/** True when `targetPath` resolves into the session-local artifact sandbox.
|
|
10
|
+
* Routes through {@link resolvePlanPath} so the guard and the eventual write
|
|
11
|
+
* always agree on the absolute target (including bracketed hashline headers,
|
|
12
|
+
* `local://` URLs, and bare absolute paths). Files inside the sandbox are not
|
|
13
|
+
* part of the working tree, so plan mode treats them as freely writable
|
|
14
|
+
* scratch/plan space — and tag-based path recovery may rebind onto them. */
|
|
15
|
+
export declare function targetsLocalSandbox(session: ToolSession, targetPath: string): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a write/edit target to its absolute filesystem path, honoring the
|
|
18
|
+
* `local://` and `vault://` schemes. Plain paths resolve against the session cwd.
|
|
19
|
+
* Bracketed hashline headers (`[path#TAG]`) are unwrapped first so the inner
|
|
20
|
+
* filesystem path drives resolution — keeping the plan-mode guard and the
|
|
21
|
+
* eventual write in lockstep.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvePlanPath(session: ToolSession, targetPath: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Plan mode keeps the working tree read-only while letting the agent draft its
|
|
26
|
+
* plan. Writes and edits to the `local://` artifact sandbox are allowed (that is
|
|
27
|
+
* where the plan and any scratch notes live); anything that would touch the
|
|
28
|
+
* working tree — or rename/delete a file — is rejected.
|
|
29
|
+
*/
|
|
30
|
+
export declare function enforcePlanModeWrite(session: ToolSession, targetPath: string, options?: {
|
|
31
|
+
move?: string;
|
|
32
|
+
op?: "create" | "update" | "delete";
|
|
33
|
+
}): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import type { ReadToolDetails } from "./read";
|
|
4
|
+
import { type SuffixMatchCache } from "./read-path-resolution";
|
|
5
|
+
import { type ParsedSelector } from "./read-selector";
|
|
6
|
+
interface ResolvedArchiveReadPath {
|
|
7
|
+
absolutePath: string;
|
|
8
|
+
archiveSubPath: string;
|
|
9
|
+
suffixResolution?: {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function resolveArchiveReadPath(session: ToolSession, readPath: string, suffixCache: SuffixMatchCache, signal?: AbortSignal): Promise<ResolvedArchiveReadPath | null>;
|
|
15
|
+
export declare function readArchive(session: ToolSession, readPath: string, parsedSel: ParsedSelector, resolvedArchivePath: ResolvedArchiveReadPath, signal?: AbortSignal): Promise<AgentToolResult<ReadToolDetails>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import { type LineEntry } from "../../omp/utils/block-context.ts";
|
|
4
|
+
import { type LineRange } from "../../omp/tools/path-utils.ts";
|
|
5
|
+
import type { ReadToolDetails } from "./read";
|
|
6
|
+
export interface HashlineHeaderContext {
|
|
7
|
+
header: string;
|
|
8
|
+
tag: string;
|
|
9
|
+
fullText?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function formatReadHashlineHeader(displayPath: string, tag: string): string;
|
|
12
|
+
export declare function readHashlineHeaderContext(session: ToolSession, absolutePath: string, cwd: string): Promise<HashlineHeaderContext>;
|
|
13
|
+
export declare function hashlineHeaderContext(displayPath: string, tag: string): HashlineHeaderContext;
|
|
14
|
+
export declare function prependHashlineHeader(text: string, context: HashlineHeaderContext | undefined): string;
|
|
15
|
+
export declare function formatTextWithMode(text: string, startNum: number, shouldAddHashLines: boolean, shouldAddLineNumbers: boolean): string;
|
|
16
|
+
export declare const BRACKET_CONTEXT_ELLIPSIS = "\u2026";
|
|
17
|
+
export declare function formatLineEntriesWithMode(entries: readonly LineEntry[], shouldAddHashLines: boolean, shouldAddLineNumbers: boolean): string;
|
|
18
|
+
/**
|
|
19
|
+
* Decide whether the kept lines surrounding an elided range collapse to a
|
|
20
|
+
* single brace-pair line in the rendered summary. Returns true when the head
|
|
21
|
+
* line ends with `{` / `(` / `[` and the tail line is the matching closer
|
|
22
|
+
* (optionally followed by terminating punctuation like `;`, `,`, or further
|
|
23
|
+
* closers — e.g. `};`, `})`, `]);`).
|
|
24
|
+
*/
|
|
25
|
+
export declare function canMergeBracePair(headLine: string, tailLine: string): boolean;
|
|
26
|
+
export declare function formatSingleLine(line: number, text: string, shouldAddHashLines: boolean, shouldAddLineNumbers: boolean): string;
|
|
27
|
+
export declare function formatMergedBraceLine(startLine: number, endLine: number, headText: string, tailText: string, shouldAddHashLines: boolean, shouldAddLineNumbers: boolean): {
|
|
28
|
+
model: string;
|
|
29
|
+
display: string;
|
|
30
|
+
};
|
|
31
|
+
export declare function countTextLines(text: string): number;
|
|
32
|
+
export declare function contiguousLineNumbers(startLine: number, count: number): number[];
|
|
33
|
+
export declare function lineNumbersFromSpans(spans: readonly {
|
|
34
|
+
startLine: number;
|
|
35
|
+
endLine: number;
|
|
36
|
+
}[]): number[];
|
|
37
|
+
/** Inclusive line range describing one elided span in a structural summary. */
|
|
38
|
+
export interface ElidedRange {
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Footer appended to summarized reads telling the model how to recover the
|
|
44
|
+
* elided body. Without this hint, agents either ignore the `…`/`{ … }`
|
|
45
|
+
* markers or burn a turn guessing the right selector (see issue #1046). The
|
|
46
|
+
* footer demonstrates the multi-range selector syntax with concrete sample
|
|
47
|
+
* ranges drawn from the actual elision so the model re-reads only what it
|
|
48
|
+
* needs instead of falling back to `:raw` or whole-file reads.
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatSummaryElisionFooter(readPath: string, elidedRanges: ReadonlyArray<ElidedRange>, elidedLines: number): string;
|
|
51
|
+
export declare const READ_CHUNK_SIZE: number;
|
|
52
|
+
/**
|
|
53
|
+
* Context lines added around an explicit range read. Anchor-stale failures
|
|
54
|
+
* cluster on edits whose anchors land just outside the most recent read
|
|
55
|
+
* window, but the data (`scripts/session-stats/analyze_selector_reads.py`)
|
|
56
|
+
* shows most follow-up reads are disjoint hops, not adjacent extensions —
|
|
57
|
+
* so symmetric padding rarely pays for itself.
|
|
58
|
+
*
|
|
59
|
+
* Leading=1 catches accidental single-line reads where the anchor is the
|
|
60
|
+
* line immediately above the requested start. Trailing=3 buffers the
|
|
61
|
+
* common case where the agent asks for a narrow range and then needs the
|
|
62
|
+
* next few lines to disambiguate an anchor.
|
|
63
|
+
*/
|
|
64
|
+
export declare const RANGE_LEADING_CONTEXT_LINES = 1;
|
|
65
|
+
export declare const RANGE_TRAILING_CONTEXT_LINES = 3;
|
|
66
|
+
export declare function buildInMemoryTextResult(session: ToolSession, text: string, offset: number | undefined, limit: number | undefined, options: {
|
|
67
|
+
details?: ReadToolDetails;
|
|
68
|
+
sourcePath?: string;
|
|
69
|
+
sourceUrl?: string;
|
|
70
|
+
sourceInternal?: string;
|
|
71
|
+
entityLabel: string;
|
|
72
|
+
ignoreResultLimits?: boolean;
|
|
73
|
+
raw?: boolean;
|
|
74
|
+
immutable?: boolean;
|
|
75
|
+
}): AgentToolResult<ReadToolDetails>;
|
|
76
|
+
/**
|
|
77
|
+
* Render a multi-range read against in-memory text. Each range emits a
|
|
78
|
+
* formatted block with its own anchors / line numbers, blocks are joined
|
|
79
|
+
* with an elision separator, and ranges past EOF surface as `[…]` notices
|
|
80
|
+
* so the model can correct the next call. No leading/trailing context is
|
|
81
|
+
* added — multi-range callers always specify exact bounds.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildInMemoryMultiRangeResult(session: ToolSession, text: string, ranges: readonly LineRange[], options: {
|
|
84
|
+
details?: ReadToolDetails;
|
|
85
|
+
sourcePath?: string;
|
|
86
|
+
sourceUrl?: string;
|
|
87
|
+
sourceInternal?: string;
|
|
88
|
+
entityLabel: string;
|
|
89
|
+
raw?: boolean;
|
|
90
|
+
immutable?: boolean;
|
|
91
|
+
}): AgentToolResult<ReadToolDetails>;
|
|
92
|
+
export declare function decodeUtf8Text(bytes: Uint8Array): string | null;
|
|
93
|
+
export declare function prependSuffixResolutionNotice(text: string, suffixResolution?: {
|
|
94
|
+
from: string;
|
|
95
|
+
to: string;
|
|
96
|
+
}): string;
|
|
97
|
+
/**
|
|
98
|
+
* Tag Markdown reads for the TUI's formatted preview, gated on the opt-in
|
|
99
|
+
* `read.renderMarkdown` setting. Off by default; when disabled, no local
|
|
100
|
+
* read is tagged `text/markdown`, so the renderer output is identical to
|
|
101
|
+
* the pre-setting behavior. Internal-URL reads keep their protocol-supplied
|
|
102
|
+
* `contentType` and render as Markdown regardless of the setting.
|
|
103
|
+
*/
|
|
104
|
+
export declare function markMarkdownContentType(session: ToolSession, details: ReadToolDetails, filePath: string): ReadToolDetails;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
2
|
+
export declare function isRemoteMountPath(absolutePath: string): boolean;
|
|
3
|
+
export declare function isNotFoundError(error: unknown): boolean;
|
|
4
|
+
/** Per-execute memo of suffix-glob lookups; `null` records a confirmed miss. */
|
|
5
|
+
export type SuffixMatchCache = Map<string, {
|
|
6
|
+
absolutePath: string;
|
|
7
|
+
displayPath: string;
|
|
8
|
+
} | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Memoized {@link findUniqueWorkspaceSuffix} for a single read call. A missing
|
|
11
|
+
* path with archive/sqlite extensions probes the workspace once per stage
|
|
12
|
+
* (archive candidates, sqlite candidates, plain path) — each glob carries a
|
|
13
|
+
* 5s timeout, so repeated lookups of the same string stack into a long
|
|
14
|
+
* stall before erroring. The cache collapses repeats within one execute().
|
|
15
|
+
*/
|
|
16
|
+
export declare function findSuffixMatchCached(session: ToolSession, cache: SuffixMatchCache, rawPath: string, signal?: AbortSignal): Promise<{
|
|
17
|
+
absolutePath: string;
|
|
18
|
+
displayPath: string;
|
|
19
|
+
} | null>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LineRange } from "../../omp/tools/path-utils.ts";
|
|
2
|
+
/** Parsed representation of a path-embedded selector. */
|
|
3
|
+
export type ParsedSelector = {
|
|
4
|
+
kind: "none";
|
|
5
|
+
} | {
|
|
6
|
+
kind: "raw";
|
|
7
|
+
} | {
|
|
8
|
+
kind: "conflicts";
|
|
9
|
+
} | {
|
|
10
|
+
kind: "lines";
|
|
11
|
+
ranges: [LineRange, ...LineRange[]];
|
|
12
|
+
raw?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** Returns true when the selector requested verbatim/raw output (alone or combined with a range). */
|
|
15
|
+
export declare function isRawSelector(parsed: ParsedSelector): boolean;
|
|
16
|
+
/** Returns true when the selector requested multiple line ranges. */
|
|
17
|
+
export declare function isMultiRange(parsed: ParsedSelector): boolean;
|
|
18
|
+
export declare function parseSel(sel: string | undefined): ParsedSelector;
|
|
19
|
+
/**
|
|
20
|
+
* Convert a single-range selector to the offset/limit pair used by internal pagination.
|
|
21
|
+
* Returns the FIRST range only — multi-range callers MUST branch on `isMultiRange` before
|
|
22
|
+
* calling this helper.
|
|
23
|
+
*/
|
|
24
|
+
export declare function selToOffsetLimit(parsed: ParsedSelector): {
|
|
25
|
+
offset?: number;
|
|
26
|
+
limit?: number;
|
|
27
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import type { ReadToolDetails } from "./read";
|
|
4
|
+
import { type SuffixMatchCache } from "./read-path-resolution";
|
|
5
|
+
interface ResolvedSqliteReadPath {
|
|
6
|
+
absolutePath: string;
|
|
7
|
+
sqliteSubPath: string;
|
|
8
|
+
queryString: string;
|
|
9
|
+
suffixResolution?: {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function resolveSqliteReadPath(session: ToolSession, readPath: string, suffixCache: SuffixMatchCache, signal?: AbortSignal): Promise<ResolvedSqliteReadPath | null>;
|
|
15
|
+
export declare function readSqlite(resolvedSqlitePath: ResolvedSqliteReadPath, signal?: AbortSignal): Promise<AgentToolResult<ReadToolDetails>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type SummaryResult } from "@oh-my-pi/pi-natives";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import { type ElidedRange } from "./read-format";
|
|
4
|
+
/**
|
|
5
|
+
* Prose files (Markdown flavors and plain text) skip code-block summarization
|
|
6
|
+
* unless `read.summarize.prose` opts them in.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isProseSummaryPath(filePath: string): boolean;
|
|
9
|
+
export declare function trySummarize(session: ToolSession, absolutePath: string, fileSize: number, signal?: AbortSignal): Promise<SummaryResult | null>;
|
|
10
|
+
export declare function renderSummary(session: ToolSession, summary: SummaryResult): {
|
|
11
|
+
text: string;
|
|
12
|
+
displayText: string;
|
|
13
|
+
elidedRanges: ElidedRange[];
|
|
14
|
+
elidedLines: number;
|
|
15
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolTier } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import type { ToolSession } from "../../omp/sdk.ts";
|
|
3
|
+
import { type TruncationResult } from "../../omp/session/streaming-output.ts";
|
|
4
|
+
import { type OutputMeta } from "../../omp/tools/output-meta.ts";
|
|
5
|
+
declare const readSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
6
|
+
path: string;
|
|
7
|
+
}, {
|
|
8
|
+
path: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type ReadToolInput = typeof readSchema.infer;
|
|
11
|
+
export interface ReadToolDetails {
|
|
12
|
+
kind?: "file" | "url";
|
|
13
|
+
truncation?: TruncationResult;
|
|
14
|
+
isDirectory?: boolean;
|
|
15
|
+
resolvedPath?: string;
|
|
16
|
+
suffixResolution?: {
|
|
17
|
+
from: string;
|
|
18
|
+
to: string;
|
|
19
|
+
};
|
|
20
|
+
/** DSH image bridge (拍板#22): committed attachment facts for an image read. */
|
|
21
|
+
image?: import("../../shared/image-bridge.ts").SavedImageRef;
|
|
22
|
+
url?: string;
|
|
23
|
+
finalUrl?: string;
|
|
24
|
+
contentType?: string;
|
|
25
|
+
method?: string;
|
|
26
|
+
notes?: string[];
|
|
27
|
+
meta?: OutputMeta;
|
|
28
|
+
/** Full on-disk byte size recorded before applying a file range. */
|
|
29
|
+
fileSize?: number;
|
|
30
|
+
/** Full source line count when the read reached EOF and the count is exact. */
|
|
31
|
+
totalLines?: number;
|
|
32
|
+
/** Raw text + start line for user-visible TUI rendering, set when content is text-like.
|
|
33
|
+
* Mirrors the same lines the model receives but without hashline/line-number prefixes,
|
|
34
|
+
* so the TUI can render the file content with its own gutter without re-parsing the formatted text. */
|
|
35
|
+
displayContent?: {
|
|
36
|
+
text: string;
|
|
37
|
+
startLine: number;
|
|
38
|
+
lineNumbers?: Array<number | null>;
|
|
39
|
+
};
|
|
40
|
+
summary?: {
|
|
41
|
+
lines: number;
|
|
42
|
+
elidedSpans: number;
|
|
43
|
+
elidedLines: number;
|
|
44
|
+
};
|
|
45
|
+
/** Number of unresolved git conflicts surfaced by this read (TUI uses for inline `⚠ N` badge). */
|
|
46
|
+
conflictCount?: number;
|
|
47
|
+
/** Paths recovered from a delimited read argument; used only by the TUI to render one call as multiple read rows. */
|
|
48
|
+
displayReadTargets?: string[];
|
|
49
|
+
}
|
|
50
|
+
type ReadParams = ReadToolInput;
|
|
51
|
+
/**
|
|
52
|
+
* Read tool implementation.
|
|
53
|
+
*
|
|
54
|
+
* Reads files with support for images, converted documents (via markit), and text.
|
|
55
|
+
* Directories return a formatted listing with modification times.
|
|
56
|
+
*/
|
|
57
|
+
export declare class ReadTool implements AgentTool<typeof readSchema, ReadToolDetails> {
|
|
58
|
+
#private;
|
|
59
|
+
private readonly session;
|
|
60
|
+
readonly name = "read";
|
|
61
|
+
readonly approval: (args: unknown) => ToolTier;
|
|
62
|
+
readonly label = "Read";
|
|
63
|
+
readonly loadMode = "essential";
|
|
64
|
+
description: string;
|
|
65
|
+
get parameters(): typeof readSchema;
|
|
66
|
+
readonly strict = true;
|
|
67
|
+
constructor(session: ToolSession);
|
|
68
|
+
execute(_toolCallId: string, params: ReadParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<ReadToolDetails>, _toolContext?: AgentToolContext): Promise<AgentToolResult<ReadToolDetails>>;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formatting helpers shared by the tool engines.
|
|
3
|
+
*
|
|
4
|
+
* The TUI renderer utilities that used to live here were cut with the TUI
|
|
5
|
+
* layer (plan.md 拍板#17); what remains is what the engines themselves use.
|
|
6
|
+
*/
|
|
7
|
+
export { replaceTabs, truncateToWidth } from "@oh-my-pi/pi-tui";
|
|
8
|
+
export { formatAge, formatBytes, formatCount, formatDuration, pluralize } from "@oh-my-pi/pi-utils";
|
|
9
|
+
/**
|
|
10
|
+
* Extract domain from URL, stripping www. prefix.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDomain(url: string): string;
|
|
13
|
+
export declare function shortenPath(filePath: unknown, homeDir?: string): string;
|
|
14
|
+
export type CodeFrameMarker = "" | " " | "*" | "+" | "-" | ">";
|
|
15
|
+
export declare function formatCodeFrameLine(marker: CodeFrameMarker, lineNumber: string | number, content: string, lineNumberWidth: number): string;
|
|
16
|
+
export declare const PARSE_ERRORS_LIMIT = 20;
|
|
17
|
+
export declare function dedupeParseErrors(errors: string[] | undefined): string[];
|
|
18
|
+
export declare function formatParseErrors(errors: string[], total?: number): string[];
|
|
19
|
+
/**
|
|
20
|
+
* Cap an upstream parse-error list to {@link PARSE_ERRORS_LIMIT} unique entries,
|
|
21
|
+
* preserving the original deduplicated total. Use this at the source so tool
|
|
22
|
+
* details never carry thousands of per-file parse errors into traces or
|
|
23
|
+
* renderers.
|
|
24
|
+
*/
|
|
25
|
+
export declare function capParseErrors(errors: string[] | undefined, limit?: number): {
|
|
26
|
+
errors: string[];
|
|
27
|
+
total: number;
|
|
28
|
+
};
|