@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,17 @@
|
|
|
1
|
+
export type ReadableFormat = "text" | "markdown";
|
|
2
|
+
export interface ReadableResult {
|
|
3
|
+
url: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
byline?: string;
|
|
6
|
+
excerpt?: string;
|
|
7
|
+
contentLength: number;
|
|
8
|
+
text?: string;
|
|
9
|
+
markdown?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extract readable content from raw HTML.
|
|
13
|
+
* Tries Readability (article-isolation scoring) first, then falls back to a
|
|
14
|
+
* CSS selector chain over the same pre-parsed DOM. Returns null if neither
|
|
15
|
+
* path yields usable content.
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractReadableFromHtml(html: string, url: string, format: ReadableFormat): Promise<ReadableResult | null>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH adapter for OMP's `config/settings-schema.ts`.
|
|
3
|
+
*
|
|
4
|
+
* The OMP schema is a ~5900-line settings registry. The edit engine only
|
|
5
|
+
* needs `getDefault(path)` for a handful of keys; defaults are taken from the
|
|
6
|
+
* OMP schema values (verbatim) so engine behavior matches upstream. Full
|
|
7
|
+
* schema metadata (tabs, UI descriptors) is DSH-side and not replicated.
|
|
8
|
+
*/
|
|
9
|
+
export type SettingPath = string;
|
|
10
|
+
export type SettingValue<P extends string = string> = unknown;
|
|
11
|
+
/** Schema default for a setting path (verbatim OMP values; unknown -> undefined). */
|
|
12
|
+
export declare function getDefault<P extends SettingPath>(path: P): any;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH adapter for OMP's `config/settings.ts` Settings surface.
|
|
3
|
+
*
|
|
4
|
+
* OMP edit engine reads session settings through `settings.get("edit.*")`,
|
|
5
|
+
* `settings.get("lsp.*")`, etc. DSH has its own configuration (fields.ts +
|
|
6
|
+
* dsh settings); this adapter maps the OMP dotted keys onto the resolved
|
|
7
|
+
* tool-plus config, so the verbatim OMP engine code compiles and runs
|
|
8
|
+
* without modification.
|
|
9
|
+
*
|
|
10
|
+
* Only the surface the edit engine actually touches is provided:
|
|
11
|
+
* - `Settings` class with `get(path)` and `getEditVariantForModel(model)`
|
|
12
|
+
* - `settings` singleton (uninitialized until `installGlobalSettings` runs)
|
|
13
|
+
* - `isSettingsInitialized()`
|
|
14
|
+
*
|
|
15
|
+
* LSP keys are not wired: the LSP integration was cut from the DSH port
|
|
16
|
+
* (plan.md §3), so those reads fall back to the schema default (their
|
|
17
|
+
* `enableLsp` gate is `false` at the call sites), never to a degraded
|
|
18
|
+
* edit path.
|
|
19
|
+
*/
|
|
20
|
+
import type { RuntimeConfig } from '../../../config/settings.ts';
|
|
21
|
+
export type SettingPath = string;
|
|
22
|
+
/** Raw settings document shape (verbatim OMP). */
|
|
23
|
+
export interface RawSettings {
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface SettingsOptions {
|
|
27
|
+
cwd?: string;
|
|
28
|
+
agentDir?: string;
|
|
29
|
+
inMemory?: boolean;
|
|
30
|
+
readOnly?: boolean;
|
|
31
|
+
overrides?: Partial<Record<string, unknown>>;
|
|
32
|
+
configFiles?: string[];
|
|
33
|
+
}
|
|
34
|
+
export type SettingValue<P extends string = string> = unknown;
|
|
35
|
+
/**
|
|
36
|
+
* Session-scoped settings adapter. `get(path)` resolves the OMP dotted key
|
|
37
|
+
* against the live tool-plus config; unknown keys return the schema default
|
|
38
|
+
* or undefined.
|
|
39
|
+
*/
|
|
40
|
+
export declare class Settings {
|
|
41
|
+
#private;
|
|
42
|
+
constructor(config: RuntimeConfig, getDefault: (path: string) => unknown);
|
|
43
|
+
get(path: string): any;
|
|
44
|
+
/** OMP storage accessor (DSH: no agent storage — null). */
|
|
45
|
+
getStorage(): null;
|
|
46
|
+
/** Whether a path is explicitly configured (DSH config is always resolved). */
|
|
47
|
+
isConfigured(_path: string): boolean;
|
|
48
|
+
/** Persist a setting (DSH: config is static at tool time — no-op). */
|
|
49
|
+
set(_path: string, _value: unknown): void;
|
|
50
|
+
/** OMP edit-variant override hook; DSH resolves the mode from config directly. */
|
|
51
|
+
getEditVariantForModel(_model: string | undefined): 'replace' | 'patch' | 'hashline' | 'apply_patch' | null;
|
|
52
|
+
}
|
|
53
|
+
/** Install the resolved tool-plus config into the global settings singleton. */
|
|
54
|
+
export declare function installGlobalSettings(config: RuntimeConfig, getDefault: (path: string) => unknown): void;
|
|
55
|
+
export declare function isSettingsInitialized(): boolean;
|
|
56
|
+
/** Global settings singleton (read-only facade over the installed config). */
|
|
57
|
+
export declare const settings: Settings;
|
|
58
|
+
/** Re-exported schema default lookup (OMP settings.ts re-exports it too). */
|
|
59
|
+
export { getDefault } from './settings-schema.ts';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser for the Codex `apply_patch` envelope format.
|
|
3
|
+
*
|
|
4
|
+
* *** Begin Patch
|
|
5
|
+
* *** Add File: <path>
|
|
6
|
+
* +<line>
|
|
7
|
+
* *** Delete File: <path>
|
|
8
|
+
* *** Update File: <path>
|
|
9
|
+
* *** Move to: <newpath>
|
|
10
|
+
* @@ <optional context>
|
|
11
|
+
* -old
|
|
12
|
+
* +new
|
|
13
|
+
* context
|
|
14
|
+
* *** End of File
|
|
15
|
+
* *** End Patch
|
|
16
|
+
*
|
|
17
|
+
* Input is the full envelope text (optionally heredoc-wrapped). Output is a
|
|
18
|
+
* list of `PatchInput` records, each ready to hand to the existing
|
|
19
|
+
* single-file `applyPatch()` in `../modes/patch.ts`.
|
|
20
|
+
*
|
|
21
|
+
* Per spec §4.3 Lenient mode: a `<<EOF` / `<<'EOF'` / `<<"EOF"` heredoc
|
|
22
|
+
* wrapper around the whole envelope is stripped before parsing.
|
|
23
|
+
*/
|
|
24
|
+
import type { PatchInput } from "../modes/patch";
|
|
25
|
+
/**
|
|
26
|
+
* Parse a Codex `*** Begin Patch` envelope into a list of single-file
|
|
27
|
+
* patch inputs.
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseApplyPatch(patchText: string): PatchInput[];
|
|
30
|
+
/**
|
|
31
|
+
* Best-effort parser for in-progress TUI previews. It tolerates missing
|
|
32
|
+
* envelope markers and incomplete trailing hunks; do not use it to apply edits.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseApplyPatchStreaming(patchText: string): PatchInput[];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit tool result detail shapes (shared by the replace / patch / hashline
|
|
3
|
+
* engines and the snapshot pruner). The TUI renderer that consumed these was
|
|
4
|
+
* cut with the TUI layer (plan.md 拍板#17); the shapes remain because the
|
|
5
|
+
* engines assemble them as their `AgentToolResult.details`.
|
|
6
|
+
*/
|
|
7
|
+
export type Operation = "create" | "delete" | "update";
|
|
8
|
+
export interface EditToolPerFileResult {
|
|
9
|
+
path: string;
|
|
10
|
+
diff: string;
|
|
11
|
+
firstChangedLine?: number;
|
|
12
|
+
op?: Operation;
|
|
13
|
+
move?: string;
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
errorText?: string;
|
|
16
|
+
/** TUI-friendly error text. When present, rendered to the user instead of `errorText`.
|
|
17
|
+
* Set when the underlying error carries a `displayMessage` (e.g. {@link HashlineMismatchError}). */
|
|
18
|
+
displayErrorText?: string;
|
|
19
|
+
meta?: OutputMeta;
|
|
20
|
+
/** Source-of-truth content before the edit; `undefined` for create operations. */
|
|
21
|
+
oldText?: string;
|
|
22
|
+
/** Source-of-truth content after the edit; `undefined` for delete operations. */
|
|
23
|
+
newText?: string;
|
|
24
|
+
/** True when {@link pruneOversizedEditSnapshots} dropped `oldText`/`newText` from this entry. Aggregators check this to suppress misleading combined snapshots when at least one entry of a multi-entry single-path edit was pruned. */
|
|
25
|
+
snapshotsPruned?: boolean;
|
|
26
|
+
/** Pre-move source path; set only when the edit moved/renamed the file. The header renders `sourcePath → path`. */
|
|
27
|
+
sourcePath?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface EditToolDetails {
|
|
30
|
+
/** Unified diff of the changes made */
|
|
31
|
+
diff: string;
|
|
32
|
+
/** Line number of the first change in the new file (for editor navigation) */
|
|
33
|
+
firstChangedLine?: number;
|
|
34
|
+
/** Operation type (patch mode only) */
|
|
35
|
+
op?: Operation;
|
|
36
|
+
/** New path after move/rename (patch mode only) */
|
|
37
|
+
move?: string;
|
|
38
|
+
/** Structured output metadata */
|
|
39
|
+
meta?: OutputMeta;
|
|
40
|
+
/** Per-file results (multi-file edits) */
|
|
41
|
+
perFileResults?: EditToolPerFileResult[];
|
|
42
|
+
/** Absolute file path for single-file edit results. Required by ACP diff metadata consumers. */
|
|
43
|
+
path?: string;
|
|
44
|
+
/** Source-of-truth content before the edit; `undefined` for create operations. */
|
|
45
|
+
oldText?: string;
|
|
46
|
+
/** Source-of-truth content after the edit; `undefined` for delete operations. */
|
|
47
|
+
newText?: string;
|
|
48
|
+
/** True when {@link pruneOversizedEditSnapshots} dropped `oldText`/`newText` from this entry. Aggregators check this to suppress misleading combined snapshots when at least one entry of a multi-entry single-path edit was pruned. */
|
|
49
|
+
snapshotsPruned?: boolean;
|
|
50
|
+
/** Pre-move source path; set only when the edit moved/renamed the file. The header renders `sourcePath → path`. */
|
|
51
|
+
sourcePath?: string;
|
|
52
|
+
}
|
|
53
|
+
type OutputMeta = import("../../edit/adapter/tools/output-meta").OutputMeta;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type BlockContextSource } from "../../omp/utils/block-context.ts";
|
|
2
|
+
export interface DiffResult {
|
|
3
|
+
diff: string;
|
|
4
|
+
firstChangedLine: number | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface DiffError {
|
|
7
|
+
error: string;
|
|
8
|
+
}
|
|
9
|
+
export interface DiffHunk {
|
|
10
|
+
changeContext?: string;
|
|
11
|
+
oldStartLine?: number;
|
|
12
|
+
newStartLine?: number;
|
|
13
|
+
hasContextLines: boolean;
|
|
14
|
+
oldLines: string[];
|
|
15
|
+
newLines: string[];
|
|
16
|
+
isEndOfFile: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class ParseError extends Error {
|
|
19
|
+
readonly lineNumber?: number | undefined;
|
|
20
|
+
constructor(message: string, lineNumber?: number | undefined);
|
|
21
|
+
}
|
|
22
|
+
export declare class ApplyPatchError extends Error {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generate a unified diff string with line numbers and context.
|
|
27
|
+
* Returns both the diff string and the first changed line number (in the new file).
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateDiffString(oldContent: string, newContent: string, contextLines?: number, source?: BlockContextSource): DiffResult;
|
|
30
|
+
export interface ReplaceOptions {
|
|
31
|
+
/** Allow fuzzy matching */
|
|
32
|
+
fuzzy: boolean;
|
|
33
|
+
/** Replace all occurrences */
|
|
34
|
+
all: boolean;
|
|
35
|
+
/** Similarity threshold for fuzzy matching */
|
|
36
|
+
threshold?: number;
|
|
37
|
+
}
|
|
38
|
+
export interface ReplaceResult {
|
|
39
|
+
/** The new content after replacements */
|
|
40
|
+
content: string;
|
|
41
|
+
/** Number of replacements made */
|
|
42
|
+
count: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generate a unified diff string without file headers.
|
|
46
|
+
* Returns both the diff string and the first changed line number (in the new file).
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateUnifiedDiffString(oldContent: string, newContent: string, contextLines?: number, source?: BlockContextSource): DiffResult;
|
|
49
|
+
export declare function normalizeDiff(diff: string): string;
|
|
50
|
+
export declare function normalizeCreateContent(content: string): string;
|
|
51
|
+
export declare function parseDiffHunks(diff: string): DiffHunk[];
|
|
52
|
+
/**
|
|
53
|
+
* Find and replace text in content using fuzzy matching.
|
|
54
|
+
*/
|
|
55
|
+
export declare function replaceText(content: string, oldText: string, newText: string, options: ReplaceOptions): ReplaceResult;
|
|
56
|
+
/**
|
|
57
|
+
* Compute the diff for an edit operation without applying it.
|
|
58
|
+
* Used for preview rendering in the TUI before the tool executes.
|
|
59
|
+
*/
|
|
60
|
+
export declare function computeEditDiff(path: string, oldText: string, newText: string, cwd: string, fuzzy?: boolean, all?: boolean, threshold?: number): Promise<DiffResult | DiffError>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit dispatch layer — path resolution + multi-entry/multi-file aggregation.
|
|
3
|
+
*
|
|
4
|
+
* Ported verbatim from upstream `packages/coding-agent/src/edit/index.ts`
|
|
5
|
+
* (refs/oh-my-pi, 17.3.5): `resolveEditPath` (:77-93), `executeApplyPatchPerFile`
|
|
6
|
+
* (:139-256) and `executeSinglePathEntries` (:258-365). Algorithm and user-facing
|
|
7
|
+
* copy are byte-for-byte upstream; only the import surface was redirected to the
|
|
8
|
+
* DSH-resident modules and the LSP-only surface was cut, per the established
|
|
9
|
+
* omp/ adaptation conventions:
|
|
10
|
+
* - `renderer` → `./details` (TUI renderer cut, plan.md 拍板#17): the
|
|
11
|
+
* `EditToolDetails` / `EditToolPerFileResult` shapes live in `./details.ts`;
|
|
12
|
+
* the upstream per-file `diagnostics` field went with the LSP layer.
|
|
13
|
+
* - `resolvePlanPath` → DSH adapter shim (`edit/adapter/tools/plan-mode-guard`,
|
|
14
|
+
* verbatim resolution minus local:// schemes) — same redirection the local
|
|
15
|
+
* engines (modes/replace.ts, modes/patch.ts) already use.
|
|
16
|
+
* - `LspBatchRequest` / `flushLspWritethroughBatch` → local type + no-op below.
|
|
17
|
+
* DSH never constructs an outer batch request, so every `batchRequest` inside
|
|
18
|
+
* the aggregators resolves to `undefined` and the flush branches stay
|
|
19
|
+
* unreachable; the flow is kept verbatim so this file stays diffable
|
|
20
|
+
* against refs.
|
|
21
|
+
*/
|
|
22
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
23
|
+
import type { ToolSession } from "../tools/index.ts";
|
|
24
|
+
import type { EditToolDetails } from "./details";
|
|
25
|
+
/**
|
|
26
|
+
* LSP write-batch handle (upstream `tools/render-utils.ts`, surfaced through the
|
|
27
|
+
* edit renderer). Shape verbatim; DSH cuts the LSP layer (plan.md 拍板#5), so no
|
|
28
|
+
* caller ever constructs one — see {@link flushLspWritethroughBatch}.
|
|
29
|
+
*/
|
|
30
|
+
export interface LspBatchRequest {
|
|
31
|
+
id: string;
|
|
32
|
+
flush: boolean;
|
|
33
|
+
}
|
|
34
|
+
export declare function resolveEditPath(session: ToolSession, authoredPath: string, options: {
|
|
35
|
+
mustExist: boolean;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<string>;
|
|
38
|
+
/** Run apply_patch file operations and aggregate their multi-file result. */
|
|
39
|
+
export declare function executeApplyPatchPerFile(fileEntries: {
|
|
40
|
+
path: string;
|
|
41
|
+
run: (batchRequest: LspBatchRequest | undefined) => Promise<AgentToolResult<EditToolDetails>>;
|
|
42
|
+
}[], outerBatchRequest: LspBatchRequest | undefined, cwd: string, signal: AbortSignal | undefined, onUpdate?: (partialResult: AgentToolResult<EditToolDetails>) => void): Promise<AgentToolResult<EditToolDetails>>;
|
|
43
|
+
export declare function executeSinglePathEntries(path: string, runs: ((batchRequest: LspBatchRequest | undefined) => Promise<AgentToolResult<EditToolDetails>>)[], outerBatchRequest: LspBatchRequest | undefined, onUpdate: ((partialResult: AgentToolResult<EditToolDetails>) => void) | undefined, cwd: string, signal: AbortSignal | undefined): Promise<AgentToolResult<EditToolDetails>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type EditStore, type EditStoreOwner } from "../../hashline/native/index.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Upper bound on the file size we snapshot.
|
|
4
|
+
*
|
|
5
|
+
* A section tag is a content hash of the *whole* file, so minting one means
|
|
6
|
+
* holding the full normalized text in the store. Files above this cap emit no
|
|
7
|
+
* `[path#tag]` header — line-anchored editing of multi-megabyte files is out
|
|
8
|
+
* of scope under the full-content model.
|
|
9
|
+
*
|
|
10
|
+
* The value mirrors the native store's own cap (`EditStore.recordSnapshotFile`
|
|
11
|
+
* returns `null` for "unreadable or larger than 4 MiB",
|
|
12
|
+
* `@oh-my-pi/pi-natives` index.d.ts:132-136); `read` also uses it to decide
|
|
13
|
+
* whether to stream a whole file into memory.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SNAPSHOT_MAX_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* Look up (or lazily create) the file snapshot store attached to a session.
|
|
18
|
+
*
|
|
19
|
+
* One-line forward to the adapter's `getEditStore` so there is exactly one
|
|
20
|
+
* store per session; the DSH name is kept because this module owns the
|
|
21
|
+
* DSH-side concerns listed in the file header.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getFileSnapshotStore(session: EditStoreOwner): EditStore;
|
|
24
|
+
/**
|
|
25
|
+
* Canonicalize an absolute path into the stable key the snapshot store uses.
|
|
26
|
+
*
|
|
27
|
+
* Different code paths reach the snapshot store via different path forms:
|
|
28
|
+
* `read local://foo.md` records under the file's `fs.realpath` (the local
|
|
29
|
+
* protocol handler resolves symlinks); a subsequent `edit` may address the
|
|
30
|
+
* same artifact via `local://foo.md`, whose resolver does NOT realpath, or
|
|
31
|
+
* via the absolute path returned in the `[path#tag]` header. macOS adds the
|
|
32
|
+
* same hazard at the working-tree level (`/tmp/...` vs `/private/tmp/...`).
|
|
33
|
+
* Collapsing every key through `realpath` makes those forms fuse onto one
|
|
34
|
+
* snapshot entry, so a freshly-minted tag is never rejected as stale just
|
|
35
|
+
* because the lookup spelled the same file differently.
|
|
36
|
+
*
|
|
37
|
+
* Non-existent paths (new-file writes) fall back to a realpath of the parent
|
|
38
|
+
* directory + basename, then to the input. This keeps creates and updates on
|
|
39
|
+
* the same canonical key.
|
|
40
|
+
*
|
|
41
|
+
* Parity note (native migration): the Rust engine keys its own lookups by
|
|
42
|
+
* `policy.cwd` + the authored path, i.e. the unresolved spelling. For a path
|
|
43
|
+
* with no symlink component the two spellings are identical; for a symlinked
|
|
44
|
+
* subpath they are not, and a tag minted here would not be found by the
|
|
45
|
+
* engine. Listed for the parity doc (T-parity) rather than papered over —
|
|
46
|
+
* native exposes no path-canonicalization hook.
|
|
47
|
+
*/
|
|
48
|
+
export declare function canonicalSnapshotKey(absolutePath: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Read the full text of `absolutePath` (within {@link SNAPSHOT_MAX_BYTES}),
|
|
51
|
+
* record it as a version snapshot, and return its content-hash tag. Returns
|
|
52
|
+
* `undefined` when the file exceeds the cap or cannot be read — callers then
|
|
53
|
+
* omit the section header so the model never sees a tag it can't anchor against.
|
|
54
|
+
*
|
|
55
|
+
* Producers that only displayed a slice of the file (range reads, search hits)
|
|
56
|
+
* use this to mint a whole-file tag: the displayed lines stay partial, but the
|
|
57
|
+
* tag fingerprints the entire file so a follow-up edit anchored at any line
|
|
58
|
+
* validates whenever the live file is byte-identical to what was read. Raw
|
|
59
|
+
* reads pass `seenLines` even though they do not emit a header, letting a prior
|
|
60
|
+
* or later same-content hashline tag inherit the raw range's provenance.
|
|
61
|
+
*
|
|
62
|
+
* `async` for call-site compatibility (`read`/`grep`/`ast-grep` await it); the
|
|
63
|
+
* native `recordSnapshotFile` performs the read, LF normalization and the
|
|
64
|
+
* 4 MiB cap synchronously, and returns `null` instead of `undefined`.
|
|
65
|
+
*/
|
|
66
|
+
export declare function recordFileSnapshot(session: EditStoreOwner, absolutePath: string, seenLines?: Iterable<number>): Promise<string | undefined>;
|
|
67
|
+
/** Merge explicit 1-indexed displayed lines into a recorded hashline snapshot. */
|
|
68
|
+
export declare function recordSeenLines(session: EditStoreOwner, absolutePath: string, tag: string, lines: readonly number[]): void;
|
|
69
|
+
/**
|
|
70
|
+
* Attach the lines a read displayed to the snapshot it minted, so the engine's
|
|
71
|
+
* (opt-in) seen-line guard can reject edits anchored on lines the model never
|
|
72
|
+
* saw. Best-effort: a no-op when the body has no numbered rows or the snapshot
|
|
73
|
+
* already aged out. `tag` must be the tag returned when this exact content was
|
|
74
|
+
* recorded. Every displayed `NN:` row counts as seen, including column-clipped
|
|
75
|
+
* rows — the guard no longer distinguishes full-width from truncated display.
|
|
76
|
+
*
|
|
77
|
+
* The `N:` / `NN-MM:` row parsing lives in Rust now
|
|
78
|
+
* (`EditStore.recordSeenLinesFromBody`, including the collapsed-summary
|
|
79
|
+
* boundary-line rule), so this is a straight forward with key canonicalization.
|
|
80
|
+
*/
|
|
81
|
+
export declare function recordSeenLinesFromBody(session: EditStoreOwner, absolutePath: string, tag: string, body: string): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Coding-agent runner that drives the native hashline engine on behalf of the
|
|
3
|
+
* `edit` tool. Converts an `{input}` tool-call payload into a fully-applied
|
|
4
|
+
* patch, wraps the result in the agent's {@link AgentToolResult} shape, and
|
|
5
|
+
* attaches `outputMeta` for the renderer.
|
|
6
|
+
*
|
|
7
|
+
* Before the native migration this file drove the vendored TS engine
|
|
8
|
+
* (`Patch`/`Patcher`/`HashlineFilesystem`/`BlockResolver`/clipboard) and
|
|
9
|
+
* hand-assembled the model-facing text from per-section fields. Upstream 18.x
|
|
10
|
+
* moved all of that into Rust (`crates/pi-edit`), so the host side is now:
|
|
11
|
+
*
|
|
12
|
+
* 1. build the `EditPolicy` (`native/policy.ts`) and the writer
|
|
13
|
+
* (`native/writer.ts`),
|
|
14
|
+
* 2. hand `EditSession.apply` the payload,
|
|
15
|
+
* 3. shape the returned {@link EditApplyOutcome} into DSH's
|
|
16
|
+
* `EditToolDetails`.
|
|
17
|
+
*
|
|
18
|
+
* What the native engine now owns (and this file therefore no longer
|
|
19
|
+
* implements — each was verified byte-for-byte against the old DSH output):
|
|
20
|
+
* the parsed/aggregated model-facing text including the compact numbered
|
|
21
|
+
* preview and `PUT N*:` block-resolution lines, mismatch / unseen-anchor /
|
|
22
|
+
* missing-file diagnostics, the byte-identical no-op hint **and** its
|
|
23
|
+
* 3-strike escalation (the old `noop-loop-guard.ts`), tag validation with
|
|
24
|
+
* in-session recovery, `N*` block resolution, the `CUT`/`PUT` clipboard
|
|
25
|
+
* registers, and the multi-section merge for sections naming one file.
|
|
26
|
+
*/
|
|
27
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
28
|
+
import { MismatchError } from "../../../hashline/native/index.ts";
|
|
29
|
+
import type { ToolSession } from "../../../omp/tools/index.ts";
|
|
30
|
+
import type { WritethroughCallback } from "../../../omp/tools/writethrough.ts";
|
|
31
|
+
import type { EditToolDetails } from "../details";
|
|
32
|
+
import { type HashlineParams, hashlineEditParamsSchema } from "./params";
|
|
33
|
+
export interface ExecuteHashlineSingleOptions {
|
|
34
|
+
session: ToolSession;
|
|
35
|
+
input: string;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
writethrough: WritethroughCallback;
|
|
38
|
+
}
|
|
39
|
+
export declare function executeHashlineSingle(options: ExecuteHashlineSingleOptions): Promise<AgentToolResult<EditToolDetails, typeof hashlineEditParamsSchema>>;
|
|
40
|
+
export { MismatchError as HashlineMismatchError, type HashlineParams, hashlineEditParamsSchema };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit mode wrapper for the Codex `apply_patch` envelope format.
|
|
3
|
+
*
|
|
4
|
+
* The mode accepts a single `input` string containing a full
|
|
5
|
+
* `*** Begin Patch ... *** End Patch` block, parses it, and fans out to
|
|
6
|
+
* the existing `executePatchSingle` — so all the machinery (plan mode,
|
|
7
|
+
* LSP writethrough, fs-cache invalidation, diagnostics) is shared with
|
|
8
|
+
* the `patch` mode.
|
|
9
|
+
*/
|
|
10
|
+
import type { PatchEditEntry } from "./patch";
|
|
11
|
+
export declare const applyPatchSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
12
|
+
input: string;
|
|
13
|
+
}, {
|
|
14
|
+
input: string;
|
|
15
|
+
}>;
|
|
16
|
+
export type ApplyPatchParams = typeof applyPatchSchema.infer;
|
|
17
|
+
export type ApplyPatchEntry = PatchEditEntry & {
|
|
18
|
+
path: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Parse the envelope and lower each hunk to a `PatchEditEntry` so it can
|
|
22
|
+
* be routed through `executePatchSingle`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function expandApplyPatchToEntries(params: ApplyPatchParams): ApplyPatchEntry[];
|
|
25
|
+
export declare function expandApplyPatchToPreviewEntries(params: ApplyPatchParams): ApplyPatchEntry[];
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Patch application logic for the edit tool.
|
|
3
|
+
*
|
|
4
|
+
* Applies parsed diff hunks to file content using fuzzy matching
|
|
5
|
+
* for robust handling of whitespace and formatting differences.
|
|
6
|
+
*/
|
|
7
|
+
import type { AgentToolResult } from "@oh-my-pi/pi-agent-core";
|
|
8
|
+
import { type WritethroughCallback } from "../../../omp/tools/writethrough.ts";
|
|
9
|
+
import type { ToolSession } from "../../../omp/tools/index.ts";
|
|
10
|
+
import type { EditToolDetails, Operation } from "../details";
|
|
11
|
+
export interface PatchInput {
|
|
12
|
+
path: string;
|
|
13
|
+
op: Operation;
|
|
14
|
+
rename?: string;
|
|
15
|
+
diff?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FileSystem {
|
|
18
|
+
exists(path: string): Promise<boolean>;
|
|
19
|
+
read(path: string): Promise<string>;
|
|
20
|
+
readBinary?: (path: string) => Promise<Uint8Array>;
|
|
21
|
+
write(path: string, content: string): Promise<void>;
|
|
22
|
+
delete(path: string): Promise<void>;
|
|
23
|
+
mkdir(path: string): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
interface FileChange {
|
|
26
|
+
type: Operation;
|
|
27
|
+
path: string;
|
|
28
|
+
newPath?: string;
|
|
29
|
+
oldContent?: string;
|
|
30
|
+
newContent?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ApplyPatchResult {
|
|
33
|
+
change: FileChange;
|
|
34
|
+
warnings?: string[];
|
|
35
|
+
}
|
|
36
|
+
export interface ApplyPatchOptions {
|
|
37
|
+
cwd: string;
|
|
38
|
+
dryRun?: boolean;
|
|
39
|
+
fuzzyThreshold?: number;
|
|
40
|
+
allowFuzzy?: boolean;
|
|
41
|
+
fs?: FileSystem;
|
|
42
|
+
/**
|
|
43
|
+
* Permit `op: "create"` to replace an existing file (full-file overwrite).
|
|
44
|
+
* The JSON `patch` edit mode sanctions create-as-overwrite for major
|
|
45
|
+
* restructures (see prompts/tools/patch.md); the Codex `apply_patch`
|
|
46
|
+
* envelope documents `*** Add File` as strictly non-overwriting and must
|
|
47
|
+
* leave this unset.
|
|
48
|
+
*/
|
|
49
|
+
allowCreateOverwrite?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/** Default filesystem implementation using Bun APIs */
|
|
52
|
+
export declare const defaultFileSystem: FileSystem;
|
|
53
|
+
/**
|
|
54
|
+
* Apply a patch operation to the filesystem.
|
|
55
|
+
*/
|
|
56
|
+
export declare function applyPatch(input: PatchInput, options: ApplyPatchOptions): Promise<ApplyPatchResult>;
|
|
57
|
+
/**
|
|
58
|
+
* Preview what changes a patch would make without applying it.
|
|
59
|
+
*/
|
|
60
|
+
export declare function previewPatch(input: PatchInput, options: ApplyPatchOptions): Promise<ApplyPatchResult>;
|
|
61
|
+
export declare function computePatchDiff(input: PatchInput, cwd: string, options?: {
|
|
62
|
+
fuzzyThreshold?: number;
|
|
63
|
+
allowFuzzy?: boolean;
|
|
64
|
+
allowCreateOverwrite?: boolean;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
diff: string;
|
|
67
|
+
firstChangedLine: number | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
error: string;
|
|
70
|
+
}>;
|
|
71
|
+
export declare const patchEditEntrySchema: import("@oh-my-pi/omptype").FluentType<{
|
|
72
|
+
op?: "delete" | "create" | "update" | undefined;
|
|
73
|
+
rename?: string | undefined;
|
|
74
|
+
diff?: string | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
op?: "delete" | "create" | "update" | undefined;
|
|
77
|
+
rename?: string | undefined;
|
|
78
|
+
diff?: string | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
export type PatchEditEntry = typeof patchEditEntrySchema.infer;
|
|
81
|
+
export declare const patchEditSchema: import("@oh-my-pi/omptype").FluentType<{
|
|
82
|
+
path: string;
|
|
83
|
+
edits: {
|
|
84
|
+
op?: "delete" | "create" | "update" | undefined;
|
|
85
|
+
rename?: string | undefined;
|
|
86
|
+
diff?: string | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
}, {
|
|
89
|
+
path: string;
|
|
90
|
+
edits: {
|
|
91
|
+
op?: "delete" | "create" | "update" | undefined;
|
|
92
|
+
rename?: string | undefined;
|
|
93
|
+
diff?: string | undefined;
|
|
94
|
+
}[];
|
|
95
|
+
}>;
|
|
96
|
+
export type PatchParams = typeof patchEditSchema.infer;
|
|
97
|
+
export interface ExecutePatchSingleOptions {
|
|
98
|
+
session: ToolSession;
|
|
99
|
+
path: string;
|
|
100
|
+
params: PatchEditEntry;
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
allowFuzzy: boolean;
|
|
103
|
+
fuzzyThreshold: number;
|
|
104
|
+
/** See {@link ApplyPatchOptions.allowCreateOverwrite}; set by the JSON `patch` mode only. */
|
|
105
|
+
allowCreateOverwrite?: boolean;
|
|
106
|
+
writethrough: WritethroughCallback;
|
|
107
|
+
}
|
|
108
|
+
export declare function executePatchSingle(options: ExecutePatchSingleOptions): Promise<AgentToolResult<EditToolDetails, typeof patchEditEntrySchema>>;
|
|
109
|
+
export {};
|