@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,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leading `cd <path> && …` workdir extraction and `~` expansion for the bash
|
|
3
|
+
* tool.
|
|
4
|
+
*
|
|
5
|
+
* Extraction delegates to `extractLeadingCdTarget` (shell-tokenize.ts, verbatim
|
|
6
|
+
* port of upstream tools/shell-tokenize.ts), so redirect prefixes, extra
|
|
7
|
+
* arguments, command substitution, and unterminated quotes all bail and leave
|
|
8
|
+
* the whole command with the shell. `~`/`~/…` prefixes expand against
|
|
9
|
+
* `os.homedir()` with upstream `expandTilde` semantics
|
|
10
|
+
* (refs packages/coding-agent/src/tools/path-utils.ts).
|
|
11
|
+
* @module @xiaoso/dsh-tool-plus/bash/cd-workdir
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Expand a leading `~`/`~/…`/`~\…` prefix to the home directory, matching
|
|
15
|
+
* upstream `expandTilde` (refs tools/path-utils.ts). A bare `~name` is joined
|
|
16
|
+
* under the home directory like upstream (user-home approximation).
|
|
17
|
+
*/
|
|
18
|
+
export declare function expandTilde(filePath: string, home?: string): string;
|
|
19
|
+
/** A leading `cd <path> && …` split into its (tilde-expanded) workdir and the remainder. */
|
|
20
|
+
export interface CdWorkdir {
|
|
21
|
+
/** Tilde-expanded working directory for the leading `cd`. */
|
|
22
|
+
workdir: string;
|
|
23
|
+
/** Command remainder after the top-level `&&`. */
|
|
24
|
+
command: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Extract a leading `cd <path> && …` prefix, expanding `~` in the target.
|
|
28
|
+
*
|
|
29
|
+
* Returns `null` when the command does not start with exactly `cd`, one path
|
|
30
|
+
* token, and a top-level `&&` — redirects (`cd /tmp 2>/dev/null && …`), extra
|
|
31
|
+
* arguments, command substitution (`$`, backticks, `(`), and unterminated
|
|
32
|
+
* quotes all leave the whole command for the shell instead of absorbing shell
|
|
33
|
+
* syntax into the structured workdir seam.
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractCdWorkdir(command: string, home?: string): CdWorkdir | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal structured logger seam for the ported bash-runtime modules.
|
|
3
|
+
* The pi-gateway originals used `createModuleLogger("…")`; dsh provides
|
|
4
|
+
* `ctx.logger` (Cordis logger), which the plugin entry installs via
|
|
5
|
+
* {@link setRuntimeLogger}. Until then a console adapter is used, so the
|
|
6
|
+
* modules stay usable outside a composition (unit tests, executor-only use).
|
|
7
|
+
* @module @xiaoso/dsh-tool-plus/logger
|
|
8
|
+
*/
|
|
9
|
+
export interface RuntimeLogger {
|
|
10
|
+
info(message: string, ...args: unknown[]): void;
|
|
11
|
+
warn(message: string, ...args: unknown[]): void;
|
|
12
|
+
error(message: string, ...args: unknown[]): void;
|
|
13
|
+
debug(message: string, ...args: unknown[]): void;
|
|
14
|
+
}
|
|
15
|
+
/** Install the composition logger (Cordis `ctx.logger`); replaces the console adapter. */
|
|
16
|
+
export declare function setRuntimeLogger(logger: RuntimeLogger): void;
|
|
17
|
+
/** The installed logger; defaults to the console adapter. */
|
|
18
|
+
export declare function runtimeLogger(): RuntimeLogger;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Portable command that rejects credential prompts without assuming an FHS layout. */
|
|
2
|
+
export declare const REJECT_PROMPT_COMMAND: string;
|
|
3
|
+
export declare const NON_INTERACTIVE_ENV: Readonly<Record<string, string>>;
|
|
4
|
+
/** Builds the per-command environment for non-interactive child processes. */
|
|
5
|
+
export declare function buildNonInteractiveEnv(overrides?: Record<string, string>, baseEnv?: Record<string, string | undefined>, platform?: NodeJS.Platform): Record<string, string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing result rendering for the bash-plus tool: output body, wall
|
|
3
|
+
* time, minimization/truncation notices, then the exit-status marker the dsh
|
|
4
|
+
* presentation layer parses back into a terminal pill.
|
|
5
|
+
*
|
|
6
|
+
* Marker contract (shared with `dsh-tool-bash`): `[exit code: N]` and
|
|
7
|
+
* `[killed by signal: X]` MUST be the final line of the rendered text —
|
|
8
|
+
* `parseExitStatus` anchors there. Other notices stay in the body.
|
|
9
|
+
* @module @xiaoso/dsh-tool-plus/render
|
|
10
|
+
*/
|
|
11
|
+
import { parseExitStatus } from '@deepseek-ai/dsh-shell';
|
|
12
|
+
import type { BashForegroundOutput, CollectedOutput } from './types.ts';
|
|
13
|
+
/** The wall-time line appended to every completed foreground result. */
|
|
14
|
+
export declare function formatWallTimeNotice(wallTimeMs: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* The OMP-form truncation notice: line-range accounting (head+tail ranges for
|
|
17
|
+
* middle elision, shown range for one-sided truncation) plus elided stats,
|
|
18
|
+
* then the spill-file pointer and a read-back hint. Range reconstruction rides
|
|
19
|
+
* the shared OMP algorithm (`outputMeta().truncationFromSummary`), with the
|
|
20
|
+
* upstream `artifact://N` clause replaced by the spill-file path — bash spill
|
|
21
|
+
* files are plain files (deliberately not registered in the read tool's
|
|
22
|
+
* artifact:// space, see adapter/spill.ts) and are recovered with `:N-M`
|
|
23
|
+
* inline selectors instead.
|
|
24
|
+
* @returns the notice lines, or `undefined` when output was not truncated.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatTruncationNotice(value: CollectedOutput): string[] | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Shape one completed run into the text the model sees. Non-zero exits are
|
|
29
|
+
* reported, not errored — the model decides how to react; only infrastructure
|
|
30
|
+
* failures (spawn errors, aborts) surface as isError results.
|
|
31
|
+
* @param value - the completed foreground run.
|
|
32
|
+
* @returns the model-facing text: output body (or `(no output)`), then wall
|
|
33
|
+
* time, minimization/truncation notices, timeout marker, and finally the
|
|
34
|
+
* exit-status marker on its own line.
|
|
35
|
+
*/
|
|
36
|
+
export declare function renderBashResult(value: BashForegroundOutput): string;
|
|
37
|
+
/**
|
|
38
|
+
* Shape one background-process read into the delta the model sees: the
|
|
39
|
+
* incremental output since the previous read, with the lossy-read notice when
|
|
40
|
+
* the in-memory tail dropped unread bytes.
|
|
41
|
+
* @param text - the incremental delta from the job producer.
|
|
42
|
+
* @param droppedBytes - bytes elided from the tail window, when any.
|
|
43
|
+
* @returns the delta text with any loss notice appended.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderJobRead(text: string, droppedBytes: number | undefined): string;
|
|
46
|
+
export { parseExitStatus };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** 运行时探测结果:`rm` 是函数(生效)/ 系统命令(未生效)/ 探测不可用。 */
|
|
2
|
+
export type RmSafeRuntime = 'function' | 'system' | 'unknown';
|
|
3
|
+
/** 注入失败原因(client 侧映射为本地化文案)。 */
|
|
4
|
+
export type RmSafeFailureReason = 'snapshot-unavailable' | 'cli-missing' | 'snapshot-write-failed' | 'runtime-not-effective';
|
|
5
|
+
/** rmSafe/status 查询结果(host RPC 返回值,client 直接消费)。 */
|
|
6
|
+
export type RmSafeStatus = {
|
|
7
|
+
status: 'disabled';
|
|
8
|
+
} | {
|
|
9
|
+
status: 'failed';
|
|
10
|
+
reason: RmSafeFailureReason;
|
|
11
|
+
} | {
|
|
12
|
+
status: 'injected';
|
|
13
|
+
runtime: RmSafeRuntime;
|
|
14
|
+
};
|
|
15
|
+
/** 查询依赖(host 侧绑定真实实现;测试注入 fake)。 */
|
|
16
|
+
export interface RmSafeStatusDeps {
|
|
17
|
+
/** 取快照路径(幂等;可能触发创建)。null = 快照不可用。 */
|
|
18
|
+
getOrCreateSnapshot: () => Promise<string | null>;
|
|
19
|
+
/** trash-cli 构建产物是否存在。 */
|
|
20
|
+
cliExists: () => boolean;
|
|
21
|
+
/** node 可执行文件路径(注入内容的一部分)。 */
|
|
22
|
+
nodePath: () => string;
|
|
23
|
+
/** trash-cli 路径(注入内容的一部分)。 */
|
|
24
|
+
cliPath: () => string;
|
|
25
|
+
/** 向快照内联追加注入(幂等)。false = 快照不可写。 */
|
|
26
|
+
inject: (snapshotPath: string, nodePath: string, cliPath: string) => boolean;
|
|
27
|
+
/** 运行时探测:新会话里 `rm` 是否被重定义。 */
|
|
28
|
+
probe: (snapshotPath: string) => Promise<RmSafeRuntime>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 解析 `type rm` / `declare -f rm` 探测输出。
|
|
32
|
+
* `rm is a function` → 函数重定义生效;其余(`rm is /usr/bin/rm`、
|
|
33
|
+
* `rm is hashed (...)`、空输出)→ 系统命令。
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseProbeOutput(stdout: string): RmSafeRuntime;
|
|
36
|
+
/**
|
|
37
|
+
* Windows 路径转 Git Bash 形式(`C:\Users\x` → `/c/Users/x`)。
|
|
38
|
+
* 非 Windows 原样返回;非盘符路径仅把反斜杠转正斜杠。
|
|
39
|
+
*/
|
|
40
|
+
export declare function toGitBashPath(p: string): string;
|
|
41
|
+
/** 一次性 shell 进程的探测结果。 */
|
|
42
|
+
export interface ProbeSpawnResult {
|
|
43
|
+
stdout: string;
|
|
44
|
+
/** 超时被杀时为 true(与退出码无关)。 */
|
|
45
|
+
timedOut: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** spawn 依赖(测试注入 fake)。 */
|
|
48
|
+
export interface ProbeSpawnDeps {
|
|
49
|
+
spawnShell: (shell: string, args: string[], timeoutMs: number) => Promise<ProbeSpawnResult>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 运行时探测:在一次性 bash 会话里 source 快照(模拟新会话创建),
|
|
53
|
+
* 然后 `type rm` + `declare -f rm` 看 `rm` 是否被重定义为函数。
|
|
54
|
+
* spawn 失败或超时 → 'unknown'(探测不可用,不代表注入失败)。
|
|
55
|
+
*/
|
|
56
|
+
export declare function probeRmSafeRuntime(shell: string, snapshotPath: string, deps?: ProbeSpawnDeps, timeoutMs?: number): Promise<RmSafeRuntime>;
|
|
57
|
+
/**
|
|
58
|
+
* 查询 rmSafe 注入状态(查询即确保注入:幂等,与 executeBash 的注入
|
|
59
|
+
* 路径一致)。rmSafe 关闭时调用方不应调用本函数(返回 disabled 由
|
|
60
|
+
* 调用方短路);此处仍兜底返回 disabled 语义由调用方保证。
|
|
61
|
+
*/
|
|
62
|
+
export declare function queryRmSafeStatus(deps: RmSafeStatusDeps): Promise<RmSafeStatus>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** 注入标记行:injectRmSafe 以此判断是否已注入(幂等)。 */
|
|
2
|
+
export declare const RM_SAFE_MARKER = "# dsh-tool-plus rmSafe";
|
|
3
|
+
/** trash-cli 构建产物路径(lib/trash-cli.mjs,与主 bundle 同目录)。 */
|
|
4
|
+
export declare function rmSafeCliPath(): string;
|
|
5
|
+
/** 单引号转义(bash 单引号内 `'\''` 表示一个字面单引号)。 */
|
|
6
|
+
export declare function quote(s: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 生成 rm 重定义脚本内容:bash 函数 `rm()` 把参数原样转交 trash-cli。
|
|
9
|
+
* 逃生口:`command rm`(bash 的 command 关键字跳过函数/alias 查找)或
|
|
10
|
+
* 绝对路径(/usr/bin/rm)走系统真删除。注意 `\rm` 反斜杠只抑制 alias
|
|
11
|
+
* 展开、不抑制函数查找,对函数重定义无效——不是逃生口。
|
|
12
|
+
*/
|
|
13
|
+
export declare function rmSafeScript(nodePath: string, cliPath: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* 向快照文件内联追加 rm 重定义(幂等:已有标记则跳过)。
|
|
16
|
+
* 返回是否注入成功;快照文件不可读/不可写时返回 false(不抛异常)。
|
|
17
|
+
*/
|
|
18
|
+
export declare function injectRmSafe(snapshotPath: string, nodePath: string, cliPath: string): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strip ANSI escape sequences, remove control characters / lone surrogates,
|
|
3
|
+
* and normalize line endings.
|
|
4
|
+
*
|
|
5
|
+
* Bun-native implementation of the former native `sanitizeText` (see
|
|
6
|
+
* `crates/pi-natives/src/text.rs::sanitize_text`). JavaScript strings are
|
|
7
|
+
* already UTF-16 code-unit arrays. `toWellFormed()` handles the uncommon
|
|
8
|
+
* malformed path; when it changes the input, replacement characters are
|
|
9
|
+
* dropped and the normalized result goes through the well-formed sanitizer.
|
|
10
|
+
*
|
|
11
|
+
* S-8 normalization: ANSI stripping re-exports the ECMA-48 state machine from
|
|
12
|
+
* `src/tools/shared/bun-shim.ts` — the same function installed as
|
|
13
|
+
* `Bun.stripANSI`; `toWellFormed()` delegates to the native
|
|
14
|
+
* `String.prototype.toWellFormed`.
|
|
15
|
+
*
|
|
16
|
+
* Fast path: well-formed input with no controls or ANSI returns the original
|
|
17
|
+
* string after the control probe.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sanitizeText(text: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Escape the three XML-significant characters (`&`, `<`, `>`) in text destined
|
|
22
|
+
* for an XML/markup element body. Allocation-conscious: returns the input
|
|
23
|
+
* unchanged (same reference) when nothing needs escaping. Quotes are left as-is
|
|
24
|
+
* — use it for element text, not attribute values.
|
|
25
|
+
*/
|
|
26
|
+
export declare function escapeXmlText(input: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Escape XML-significant characters for an attribute VALUE: the three body
|
|
29
|
+
* characters (`&`, `<`, `>`) plus the double quote (`"` → `"`) that would
|
|
30
|
+
* otherwise close the attribute. Allocation-conscious: returns the input
|
|
31
|
+
* unchanged (same reference) when nothing needs escaping. Use it for attribute
|
|
32
|
+
* values; {@link escapeXmlText} is for element bodies and leaves `"` intact.
|
|
33
|
+
*/
|
|
34
|
+
export declare function escapeXmlAttribute(input: string): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell environment snapshot for preserving user aliases, functions, and options.
|
|
3
|
+
*
|
|
4
|
+
* Creates a snapshot file that captures the user's shell environment from their
|
|
5
|
+
* .bashrc/.zshrc, which can be sourced before each command to provide a familiar
|
|
6
|
+
* shell experience.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Strip alias definitions brush's whitespace-only expander cannot execute.
|
|
10
|
+
*
|
|
11
|
+
* Returns the rewritten snapshot plus the list of dropped alias names so the
|
|
12
|
+
* caller can surface them in the debug log.
|
|
13
|
+
*/
|
|
14
|
+
export declare function sanitizeSnapshotForBrush(content: string): {
|
|
15
|
+
content: string;
|
|
16
|
+
dropped: string[];
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Create a shell snapshot, caching the result.
|
|
20
|
+
* Returns the path to the snapshot file, or null if creation failed.
|
|
21
|
+
*
|
|
22
|
+
* `timeoutMs` is configurable so callers exercising failure handling do not
|
|
23
|
+
* have to wait out the production startup budget.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getOrCreateSnapshot(shell: string, env: Record<string, string | undefined>, timeoutMs?: number): Promise<string | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Delete every cached snapshot file and clear the cache. Called from the
|
|
28
|
+
* plugin's disposal path (the pi-gateway original ran this through its
|
|
29
|
+
* postmortem registry).
|
|
30
|
+
*/
|
|
31
|
+
export declare function cleanupSnapshots(): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conservative shell command tokenizer shared by the bash approval-pattern
|
|
3
|
+
* matcher and the gh-cache invalidator.
|
|
4
|
+
*
|
|
5
|
+
* Splits a bash command into independent command segments, each a list of word
|
|
6
|
+
* tokens. Handles single/double-quoted strings, backslash escapes, and the
|
|
7
|
+
* standard operators (`;`, `&&`, `||`, `|`, `&`, `(`, `)`, newlines) as segment
|
|
8
|
+
* boundaries so callers treat the pieces as independent command sequences.
|
|
9
|
+
*
|
|
10
|
+
* It is deliberately not a full POSIX parser — heredocs, command substitution,
|
|
11
|
+
* and arithmetic expansion are out of scope; callers fall through when they
|
|
12
|
+
* cannot find the structure they need.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tokenizeShellSegments(command: string): string[][];
|
|
15
|
+
/**
|
|
16
|
+
* A flat shell command segment with the context needed to decide interception.
|
|
17
|
+
*
|
|
18
|
+
* @see extractFlatShellCommandSegments
|
|
19
|
+
*/
|
|
20
|
+
interface FlatShellCommandSegment {
|
|
21
|
+
/** Original segment text with quoting and escaping preserved. */
|
|
22
|
+
text: string;
|
|
23
|
+
/**
|
|
24
|
+
* True when this segment consumes the previous stage's stdout via an
|
|
25
|
+
* unquoted `|` or `|&`. Blank and comment-only continuation lines preserve
|
|
26
|
+
* the pending pipe state. Such a stage reads piped stdin, so path-based
|
|
27
|
+
* dedicated tools (read/grep/glob) cannot replace it. `||`, `;`, `&`, and
|
|
28
|
+
* `&&` start an independent command and leave this false.
|
|
29
|
+
*/
|
|
30
|
+
pipedStdin: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the flat shell command segments with the original text of each. Unlike
|
|
34
|
+
* `tokenizeShellSegments`, this preserves quoting and escaping so the results
|
|
35
|
+
* are safe to match against user-configured regular expressions, and flags
|
|
36
|
+
* segments that receive piped stdin.
|
|
37
|
+
*
|
|
38
|
+
* The extractor deliberately declines to split syntax whose execution context
|
|
39
|
+
* cannot be determined with this small scanner (heredocs, command substitution,
|
|
40
|
+
* backticks, grouping, and malformed quoting). Callers must still check the
|
|
41
|
+
* complete input in that case.
|
|
42
|
+
*/
|
|
43
|
+
export declare function extractFlatShellCommandSegments(command: string): FlatShellCommandSegment[];
|
|
44
|
+
/**
|
|
45
|
+
* Parses a leading `cd <path> && ...` prefix so the bash tool can route the
|
|
46
|
+
* target through its structured `cwd` parameter when the model omits it.
|
|
47
|
+
*
|
|
48
|
+
* Returns the single path token (quotes and backslash escapes resolved to their
|
|
49
|
+
* literal value) and the command remainder after the top-level `&&`, or `null`
|
|
50
|
+
* when the command does not begin with exactly `cd`, one path token, and a
|
|
51
|
+
* top-level `&&`. The scanner deliberately bails on anything else in the prefix
|
|
52
|
+
* — redirects (`cd /tmp 2>/dev/null && ...`), extra arguments, or paths needing
|
|
53
|
+
* shell expansion (`$`, backticks, `(`) — leaving the whole command for the
|
|
54
|
+
* shell instead of absorbing shell syntax into `cwd`.
|
|
55
|
+
*/
|
|
56
|
+
export declare function extractLeadingCdTarget(command: string): {
|
|
57
|
+
path: string;
|
|
58
|
+
rest: string;
|
|
59
|
+
} | null;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OutputSink as VerbatimOutputSink, OutputSummary as VerbatimOutputSummary, type OutputSinkOptions } from "../omp/session/streaming-output.ts";
|
|
2
|
+
export * from "../omp/session/streaming-output.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Verbatim `OutputSummary` 加 DSH 增量字段 `artifactPath`。
|
|
5
|
+
*/
|
|
6
|
+
export interface OutputSummary extends VerbatimOutputSummary {
|
|
7
|
+
/**
|
|
8
|
+
* Path of the spill file mirroring the raw stream, when one was created.
|
|
9
|
+
* Present even when only the per-line column cap triggered mirroring.
|
|
10
|
+
*/
|
|
11
|
+
artifactPath?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class OutputSink extends VerbatimOutputSink {
|
|
14
|
+
#private;
|
|
15
|
+
constructor(options?: OutputSinkOptions);
|
|
16
|
+
dump(notice?: string): Promise<OutputSummary>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Composition wrapper over the verbatim {@link TailBuffer}, adding the DSH
|
|
20
|
+
* `reset()` increment. The verbatim class keeps its state in private fields,
|
|
21
|
+
* so reset is modeled as a fresh window with the same budget.
|
|
22
|
+
*/
|
|
23
|
+
export declare class TailBuffer {
|
|
24
|
+
#private;
|
|
25
|
+
readonly maxBytes: number;
|
|
26
|
+
constructor(maxBytes: number);
|
|
27
|
+
append(text: string): void;
|
|
28
|
+
text(): string;
|
|
29
|
+
bytes(): number;
|
|
30
|
+
/** Drop all held output; the next {@link append} starts a fresh window. */
|
|
31
|
+
reset(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** 解析后的 rm 参数。 */
|
|
2
|
+
export interface ParsedRmArgs {
|
|
3
|
+
recursive: boolean;
|
|
4
|
+
force: boolean;
|
|
5
|
+
interactive: boolean;
|
|
6
|
+
verbose: boolean;
|
|
7
|
+
dir: boolean;
|
|
8
|
+
/** --preserve-root(默认开启,对齐 GNU rm)。 */
|
|
9
|
+
preserveRoot: boolean;
|
|
10
|
+
/** --one-file-system(接受并忽略:trash 原子移动无递归遍历)。 */
|
|
11
|
+
oneFileSystem: boolean;
|
|
12
|
+
paths: string[];
|
|
13
|
+
error?: {
|
|
14
|
+
kind: 'missing-operand';
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'invalid-option';
|
|
17
|
+
option: string;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'unrecognized-option';
|
|
20
|
+
option: string;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'invalid-argument';
|
|
23
|
+
option: string;
|
|
24
|
+
value: string;
|
|
25
|
+
} | {
|
|
26
|
+
kind: 'option-argument';
|
|
27
|
+
option: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 解析 rm 风格参数(coreutils rm 语义):
|
|
32
|
+
* - 短选项支持组合(`-rf`),`-r`/`-R`/`--recursive` 等价,`-i`/`-I` 等价;
|
|
33
|
+
* - `--` 结束符后全部视为路径(允许 `-` 开头的文件名);
|
|
34
|
+
* - `--interactive[=once|always|never]` 接受(回收站模式忽略交互);
|
|
35
|
+
* - 未知短选项 → invalid-option,未知长选项 → unrecognized-option;
|
|
36
|
+
* - 无路径 → missing-operand。
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseRmArgs(argv: string[]): ParsedRmArgs;
|
|
39
|
+
/** trash 层与 IO 依赖(单测注入 fake)。 */
|
|
40
|
+
export interface TrashCliDeps {
|
|
41
|
+
trash: (paths: string[]) => Promise<void>;
|
|
42
|
+
/** lstat 语义:链接本身存在即可删;返回 null = 不存在。 */
|
|
43
|
+
lstat: (p: string) => Promise<{
|
|
44
|
+
isDirectory: boolean;
|
|
45
|
+
} | null>;
|
|
46
|
+
/** stat 语义:返回 dev/ino 用于根目录判定(GNU preserve-root 的 dev/ino 比较);失败返回 null。 */
|
|
47
|
+
stat: (p: string) => Promise<{
|
|
48
|
+
dev: number;
|
|
49
|
+
ino: number;
|
|
50
|
+
} | null>;
|
|
51
|
+
stdout: (s: string) => void;
|
|
52
|
+
stderr: (s: string) => void;
|
|
53
|
+
exit: (code: number) => void;
|
|
54
|
+
/** rename 探测(默认实现 fs.rename 到同目录临时名再改回)。返回 errno 码或 null(可移动)。 */
|
|
55
|
+
probeRename?: (from: string, to: string) => Promise<string | null>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* rename 探测结果 → 可读原因(null = 无结论)。
|
|
59
|
+
*
|
|
60
|
+
* trash 的 windows-trash.exe 失败时把原因吞成 0x8000FFFF、stderr 为空,
|
|
61
|
+
* 所以这里靠 rename 探测拿文件系统的真实回答;不同 errno 必须分开报,
|
|
62
|
+
* 权限不足不是“被占用”。
|
|
63
|
+
*/
|
|
64
|
+
export declare function describeProbeCode(code: string | null): string | null;
|
|
65
|
+
/**
|
|
66
|
+
* 执行一次 rm 语义的回收站删除。
|
|
67
|
+
*
|
|
68
|
+
* 行为对齐 coreutils rm:
|
|
69
|
+
* - 无 -r/-d 时目录报 `Is a directory` 并保留(rm4);
|
|
70
|
+
* - 不存在路径:-f 静默忽略(f-1),否则报 `No such file or directory`;
|
|
71
|
+
* - `.`/`..` 结尾路径拒绝(r-4);`/` 及同义词拒绝(r-root,preserve-root 默认开);
|
|
72
|
+
* - 符号链接按链接本身处理(lstat,dangling-symlink 移植);
|
|
73
|
+
* - trash 失败:-f 静默但退出 1,否则报 `cannot remove`;
|
|
74
|
+
* - -v 输出 `removed 'x'` / `removed directory 'x'`(r-1/d-1/v-slash);
|
|
75
|
+
* - 退出码:全部成功 0,任一失败 1。
|
|
76
|
+
*/
|
|
77
|
+
export declare function runTrashCli(argv: string[], deps: TrashCliDeps): Promise<void>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin configuration, tool argument, and result DTO types for the ported
|
|
3
|
+
* Oh My Pi bash tool. The runtime `Config` schema lives in `index.ts`.
|
|
4
|
+
* @module @xiaoso/dsh-tool-plus/types
|
|
5
|
+
*/
|
|
6
|
+
/** Minimizer settings mirroring the native `MinimizerOptions` surface. */
|
|
7
|
+
export interface MinimizerConfig {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
/** Restrict minimization to these filter names (empty = all). */
|
|
10
|
+
only: string[];
|
|
11
|
+
/** Exclude these filter names from minimization. */
|
|
12
|
+
except: string[];
|
|
13
|
+
/** Output capture budget in bytes; larger outputs pass through raw. */
|
|
14
|
+
maxCaptureBytes: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Runtime configuration schema for the plugin; declared in `index.ts`
|
|
18
|
+
* alongside `apply`. Every field is optional at the composition boundary and
|
|
19
|
+
* defaults inside `apply`; {@link ResolvedConfig} is the fully-defaulted form.
|
|
20
|
+
*/
|
|
21
|
+
export interface Config {
|
|
22
|
+
/** Expose `run_in_background` (default true); disabled calls are also rejected. */
|
|
23
|
+
enableRunInBackground?: boolean;
|
|
24
|
+
/** Foreground commands exceeding this wall time are moved to the background (0 = never). */
|
|
25
|
+
autoBackgroundMs?: number;
|
|
26
|
+
/** Deadline applied when the model omits `timeoutMs`. */
|
|
27
|
+
defaultTimeoutMs?: number;
|
|
28
|
+
/** Upper clamp for explicit timeouts; `timeoutMs: 0` disables the deadline. */
|
|
29
|
+
maxTimeoutMs?: number;
|
|
30
|
+
/** Tail budget for live previews and background-job output reads. */
|
|
31
|
+
outputMaxBytes?: number;
|
|
32
|
+
/** OutputSink rolling tail window (bytes). */
|
|
33
|
+
outputSinkTailBytes?: number;
|
|
34
|
+
/** OutputSink head window (bytes) retained in addition to the tail. */
|
|
35
|
+
outputSinkHeadBytes?: number;
|
|
36
|
+
/** Output minimizer (native intelligent compression for git/npm/cargo/…). */
|
|
37
|
+
minimizer?: MinimizerConfig;
|
|
38
|
+
/** Block intercepted commands and suggest the dedicated dsh tool instead. */
|
|
39
|
+
interceptorEnabled?: boolean;
|
|
40
|
+
/** Harden the command environment for non-interactive use (pagers, prompts, color). */
|
|
41
|
+
nonInteractiveEnv?: boolean;
|
|
42
|
+
/** Capture the user's rc file (aliases, functions, options) into the session shell. */
|
|
43
|
+
snapshotEnabled?: boolean;
|
|
44
|
+
/** Redefine `rm` in the session shell to move into the system trash; the plugin config layer decides the default (rmSafe: true). */
|
|
45
|
+
rmSafe?: boolean;
|
|
46
|
+
/** Wrap every command in `bash -c '…'` for a full bash environment. */
|
|
47
|
+
useShellCommandWrapper?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/** {@link Config} with every field resolved to its default. */
|
|
50
|
+
export type ResolvedConfig = Required<Config>;
|
|
51
|
+
/** Parsed tool arguments; execute validates value constraints absent from ParameterSchemaSpec. */
|
|
52
|
+
export interface BashToolArgs {
|
|
53
|
+
command: string;
|
|
54
|
+
description: string;
|
|
55
|
+
timeoutMs?: number;
|
|
56
|
+
workdir?: string;
|
|
57
|
+
env?: Record<string, string>;
|
|
58
|
+
run_in_background?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Minimizer facts surfaced with a foreground result. */
|
|
61
|
+
export interface MinimizedOutputInfo {
|
|
62
|
+
filter: string;
|
|
63
|
+
inputBytes: number;
|
|
64
|
+
outputBytes: number;
|
|
65
|
+
}
|
|
66
|
+
/** One collected output stream (single merged stdout+stderr, like the native Shell). */
|
|
67
|
+
export interface CollectedOutput {
|
|
68
|
+
text: string;
|
|
69
|
+
truncated: boolean;
|
|
70
|
+
/** Path of the spill file mirroring the full raw output stream, when one was created. */
|
|
71
|
+
spillPath?: string;
|
|
72
|
+
/** Path holding the pre-minimization original text, when the native minimizer rewrote the output. */
|
|
73
|
+
originalSpillPath?: string;
|
|
74
|
+
/** Stream counters carried for the truncation notice (OMP OutputSummary parity). */
|
|
75
|
+
totalLines?: number;
|
|
76
|
+
totalBytes?: number;
|
|
77
|
+
outputLines?: number;
|
|
78
|
+
outputBytes?: number;
|
|
79
|
+
elidedLines?: number;
|
|
80
|
+
elidedBytes?: number;
|
|
81
|
+
}
|
|
82
|
+
/** Foreground completion of one bash call. */
|
|
83
|
+
export interface BashForegroundOutput {
|
|
84
|
+
kind: 'foreground';
|
|
85
|
+
/** Process exit code; null when the run was interrupted before exit. */
|
|
86
|
+
exitCode: number | null;
|
|
87
|
+
timedOut: boolean;
|
|
88
|
+
aborted: boolean;
|
|
89
|
+
/** The effective deadline in ms (null when the deadline was disabled). */
|
|
90
|
+
timeoutMs: number | null;
|
|
91
|
+
/** Wall-clock duration of the run. */
|
|
92
|
+
wallTimeMs: number;
|
|
93
|
+
/** The shell's working directory after the command (persists across calls). */
|
|
94
|
+
workingDir?: string;
|
|
95
|
+
/** Present when the native minimizer rewrote the output. */
|
|
96
|
+
minimized?: MinimizedOutputInfo;
|
|
97
|
+
/** True when the rmSafe injection failed: `rm` deletes permanently. */
|
|
98
|
+
rmSafeInjectionFailed?: boolean;
|
|
99
|
+
output: CollectedOutput;
|
|
100
|
+
}
|
|
101
|
+
/** Background acknowledgement: the call returned a managed job id. */
|
|
102
|
+
export interface BashBackgroundOutput {
|
|
103
|
+
kind: 'background';
|
|
104
|
+
jobId: string;
|
|
105
|
+
}
|
|
106
|
+
/** The tool's canonical output DTO. */
|
|
107
|
+
export type BashOutput = BashForegroundOutput | BashBackgroundOutput;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal PATH (+ PATHEXT on Windows) executable lookup — the plugin's single
|
|
3
|
+
* implementation of `Bun.which` semantics on the Node runtime.
|
|
4
|
+
*
|
|
5
|
+
* Two callers, one scanner: DSH code that must resolve executables the way OMP
|
|
6
|
+
* does (procmgr `resolveWindowsShell` for shell discovery, `REJECT_PROMPT_COMMAND`
|
|
7
|
+
* in non-interactive-env) calls `findOnPath` directly, and the bun-shim installs
|
|
8
|
+
* `Bun.which` on top of it — which is also how upstream pi-utils' `$which` lands
|
|
9
|
+
* here (@oh-my-pi/pi-utils src/which.ts:201 calls `Bun.which` on non-darwin).
|
|
10
|
+
* Single implementation — any new caller resolves executables through here,
|
|
11
|
+
* never hand-rolls a PATH walk.
|
|
12
|
+
* @module @xiaoso/dsh-tool-plus/bash/which
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Resolve `command` against PATH the way `Bun.which` would: absolute/relative
|
|
16
|
+
* candidates are returned as-is when they name an existing file; bare names
|
|
17
|
+
* are looked up in each PATH dir (appending PATHEXT extensions on win32, in
|
|
18
|
+
* order). Returns the first existing regular file, or `undefined`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function findOnPath(command: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows shell discovery, ported from oh-my-pi procmgr's `resolveWindowsShell`
|
|
3
|
+
* (refs/oh-my-pi/packages/utils/src/procmgr.ts:148-173) — adapted verbatim:
|
|
4
|
+
* `Bun.env` → injectable Node env (default `process.env`), and pi-utils
|
|
5
|
+
* `$which` → `findOnPath` (src/tools/bash/which.ts).
|
|
6
|
+
*
|
|
7
|
+
* Deliberately NOT ported from procmgr: buildSpawnEnv, shell prefix handling,
|
|
8
|
+
* direnv integration, and PI_SHELL_PREFIX — DSH has no shell-prefix seam;
|
|
9
|
+
* commands run inside the embedded brush shell or the resolved user shell.
|
|
10
|
+
* @module @xiaoso/dsh-tool-plus/bash/windows-shell
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the external shell to advertise on Windows.
|
|
14
|
+
*
|
|
15
|
+
* A host bash is OPTIONAL: bash tool commands always execute in the embedded
|
|
16
|
+
* brush-core shell. The resolved binary only serves the spawn-a-shell paths,
|
|
17
|
+
* so this prefers a real Git Bash when one exists and otherwise falls back to
|
|
18
|
+
* cmd.exe — it never fails.
|
|
19
|
+
*
|
|
20
|
+
* Search order:
|
|
21
|
+
* 1. Git for Windows install roots (machine + per-user installers)
|
|
22
|
+
* 2. scoop installs — scoop's git manifest sets GIT_INSTALL_ROOT and shims
|
|
23
|
+
* sh.exe/git.exe but never bash.exe, so PATH lookup alone misses it
|
|
24
|
+
* 3. bash.exe on PATH (Cygwin, MSYS2, ...)
|
|
25
|
+
* 4. sh.exe on PATH (Git for Windows' sh.exe is bash; prefer a sibling
|
|
26
|
+
* bash.exe when present)
|
|
27
|
+
* 5. cmd.exe from ComSpec
|
|
28
|
+
*
|
|
29
|
+
* Exported for tests; `env` overrides process.env-based discovery.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveWindowsShell(env?: NodeJS.ProcessEnv): string;
|